473,405 Members | 2,287 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

How to get CurrentCell location in DataGridView?

I can find the X and Y (column/row) coordinates, but not the actual location
(Left,Top) positions.

Any ideas?

Lennart
Feb 7 '07 #1
5 32527
You want the cell position ? X and Y coordinates ?
If it is that what u mean, u need to calculate the position using the DGV
left position + width of each cell

Ex:

If u need the position of cell nr 3... u need something like this:

position = dgv.left + dgv.rows(0).width + dgv.rows(1).width +
dgv.rows(2).width

If u don't want this, try explain better your problem.

--

Tiago Salgado

http://weblogs.pontonetpt.com/tiagosalgado
http://www.foruns.org
http://www.portugal-a-programar.org
http://www.revista-programar.info

"Lennart Nielsen" <LN******@uni-systems.comwrote in message
news:uX**************@TK2MSFTNGP06.phx.gbl...
>I can find the X and Y (column/row) coordinates, but not the actual
location (Left,Top) positions.

Any ideas?

Lennart

Feb 8 '07 #2
You might be able to use the dataGridView1.GetCellDisplayRectangle
method to get the information you want.

===============
Clay Burch
Syncfusion, Inc.

Feb 8 '07 #3
Clay,

No, that just gives me the column and row index.

lennart

"ClayB" <cl***@syncfusion.comwrote in message
news:11**********************@l53g2000cwa.googlegr oups.com...
You might be able to use the dataGridView1.GetCellDisplayRectangle
method to get the information you want.

===============
Clay Burch
Syncfusion, Inc.

Feb 8 '07 #4
Lennart Nielsen wrote:
Clay,

No, that just gives me the column and row index.

lennart

I have a DataGridView control called "Grd" and I need to know the bottom
left-hand pixel of the Selected Cell during Cell Editing, I use the
following in the "Grd.CellBeginEdit" and it works perfectly -

Dim X As Integer = Grd.GetCellDisplayRectangle(e.ColumnIndex,
e.RowIndex, False).Left + Grd.Left
Dim Y As Integer = Grd.GetCellDisplayRectangle(e.ColumnIndex,
e.RowIndex, False).Bottom + Grd.Top

You can play with different Properties such as Right, Top etc. Remember
that your DataGridView control is sitting inside a container (either a
Form or maybe a Layout control, or maybe both!) so you must allow for
the position of the DataGridView control in your calculations, which is
why I use "Grd.Top" and "Grd.Left".

Hope this helps.

ShaneO

There are 10 kinds of people - Those who understand Binary and those who
don't.
Feb 8 '07 #5
Indeed, Clay and ShaneO, you are both correct. I had a brain melt and did
not look for the properties of GetCellDisplayRectangle. Sorry for doubting
you!

Thanks!

Lennart

"ShaneO" <sp****@optusnet.com.auwrote in message
news:45**********************@news.optusnet.com.au ...
Lennart Nielsen wrote:
>Clay,

No, that just gives me the column and row index.

lennart

I have a DataGridView control called "Grd" and I need to know the bottom
left-hand pixel of the Selected Cell during Cell Editing, I use the
following in the "Grd.CellBeginEdit" and it works perfectly -

Dim X As Integer = Grd.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex,
False).Left + Grd.Left
Dim Y As Integer = Grd.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex,
False).Bottom + Grd.Top

You can play with different Properties such as Right, Top etc. Remember
that your DataGridView control is sitting inside a container (either a
Form or maybe a Layout control, or maybe both!) so you must allow for the
position of the DataGridView control in your calculations, which is why I
use "Grd.Top" and "Grd.Left".

Hope this helps.

ShaneO

There are 10 kinds of people - Those who understand Binary and those who
don't.

Feb 8 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Strahimir Antoljak | last post by:
Is it possible (and how?) to get the data grid column name based on the DataGrid.CurrentCell? The DataGrid has assigned a TableStyle comprising selected columns (DataGridTextBoxColumn) from the...
1
by: melanieab | last post by:
Hi, I have a datagrid & a datatable, and when I use the mousemove event, I run into trouble. private void dgMouseMove(object sender, System.Windows.Forms.MouseEventArgs e) {...
7
by: Mitchell S. Honnert | last post by:
Is there an equivalent of the DataGrid's DataGridTableStyle for the DataGridView? If not, is there an easy way to duplicate the DataGridTableStyle's functionality for the DataGridView? Here's...
2
by: sklett | last post by:
I have a 2 column DGV. When a user enters a value in cell 0,0 I want to set cell 0,1 as current, when they enter a value in cell 0,1 I want to set cell 1,0 current, etc, etc basically...
0
by: jeastman - Hotmail | last post by:
Hello world Excuse, not to be written English and it helps me with a translator. I am new programming in C#. I made a control inheriting the DataGridView to be able to add controls done by...
4
by: Michel Walsh | last post by:
Someone has an example, C#, about how to set the cell(int row, int col) as the current cell for a DataGridView. The example, in the help file, about DataGrid.CurrentCell Property (Set) ...
1
by: =?Utf-8?B?UmljaA==?= | last post by:
I placed a button on a form menustrip for the purpose of causing the horizontal scrollbar of my form to appear so that I can access controls outside of the form's current view (the controls are...
3
by: Andrus | last post by:
I have DataGridView in virtual mode containing 3500 rows. In code below, assigning to RowCount value to 3500 takes 8 seconds. CPU usage goes high at this time. Stepping by F11 into user code shows...
4
Luckie
by: Luckie | last post by:
Hi All experts there, I am developing a software using datagridview (vb6 feels better) and i am using virtualMode. it shows the focus blue box but it is not possible to fill data to the first...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.