Articles in this section
Category / Section

How to use the PointToRowCol method in WinForms GridGroupingControl?

1 min read

Use of PointToRowCol method


To retrieve the row and column index from the mouse position, the PointToRowCol method can be used. In the example below, the row and column indices are taken from the mouse down point.


C#

this.gridGroupingControl1.TableControl.MouseDown += TableControl_MouseDown;
 
void TableControl_MouseDown(object sender, MouseEventArgs e)
{
   System.Drawing.Point _Ponto;
   _Ponto = new System.Drawing.Point(e.X, e.Y);
   int row, col;
   gridGroupingControl1.TableControl.PointToRowCol(_Ponto, out row, out col);
   MessageBox.Show("Row :" + row + "\n" + "Col   :" + col);
}

VB

AddHandler Me.gridGroupingControl1.TableControl.MouseDown, AddressOf TableControl_MouseDown

Private Sub TableControl_MouseDown(ByVal sender As Object, ByVal e As MouseEventArgs)
    Dim _Ponto As System.Drawing.Point = New System.Drawing.Point(e.X, e.Y)
    Dim row As Integer, col As Integer
    Me.gridGroupingControl1.TableControl.PointToRowCol(_Ponto, row, col)
    MessageBox.Show("Row :" & row & vbCrLf & "Col   :" & col)
End Sub

The screenshot below illustrates the row and column indices in GridGroupingControl.

Show the row and column count


Samples:

C#: PointToRowCol

VB: PointToRowCol

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied