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
Printable View
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
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?
SDorry DataGridView
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.
I have, can you point it out for me. it's not the grid i'm after but selected cells.
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
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.