|
-
Apr 24th, 2010, 10:26 PM
#1
Thread Starter
Fanatic Member
Datagrid Cell Coordinate
How can I find the X and Y position of a datagrid cell? I can provide the row and cell number if needed.
Thanks heaps
-
Apr 24th, 2010, 10:29 PM
#2
Re: Datagrid Cell Coordinate
Is it really a DataGrid, or is it actually a DataGridView? If it's a DataGrid, is it really a WinForms DataGrid, or is it aactually an ASP.NET or WPF DataGrid?
-
Apr 24th, 2010, 10:55 PM
#3
Thread Starter
Fanatic Member
Re: Datagrid Cell Coordinate
-
Apr 24th, 2010, 11:05 PM
#4
Re: Datagrid Cell Coordinate
Have you read the documentation for the DataGridView class? You should, because the answer to your question is in there. You should always read the relevant documentation first.
-
Apr 24th, 2010, 11:27 PM
#5
Thread Starter
Fanatic Member
Re: Datagrid Cell Coordinate
I have, can you point it out for me. it's not the grid i'm after but selected cells.
-
Apr 25th, 2010, 12:09 AM
#6
Thread Starter
Fanatic Member
Re: Datagrid Cell Coordinate
I have this but how can I loop through all cells not just 'selected' cells
vb Code:
Dim cell As DataGridViewCell
For Each cell In DataGridView1.SelectedCells
If cell.Value.ToString = String.Empty Then
MessageBox.Show("Empty")
'Dim newTXT As New TextBox
'newTXT.Text = "DD"
End If
Dim r As Rectangle = DataGridView1.GetCellDisplayRectangle(DataGridView1.CurrentCellAddress.X, DataGridView1.CurrentCellAddress.Y, False)
MessageBox.Show(r.X & " - " & r.Y)
Next
-
Apr 25th, 2010, 12:57 AM
#7
Re: Datagrid Cell Coordinate
You would use two nested loops. You could either use For Each loops, looping through the Rows of the grid and then the Cells of the row, or you could use For loops using the RowCount and ColumnCount and indexing the grid itself by column index and row index.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|