DataGrid.HitTestInfo Class
Assembly: System.Windows.Forms (in system.windows.forms.dll)
The DataGrid.HitTestInfo class, in conjunction with the HitTest method of the DataGrid control, is used to determine which part of a DataGrid control the user has clicked. The DataGrid.HitTestInfo class contains the row, column, and part of the grid that was clicked. See the DataGrid.HitTestType enumeration returned by the Type property for a complete list of grid parts.
To return a DataGrid.HitTestInfo, invoke the HitTest method from the MouseDown event of DataGrid control. Pass the x and y properties of the MouseEventArgs to the HitTest method.
The following example uses the HitTest method in a MouseDown event to return the DataGrid.HitTestInfo object. The row, column, and part of the grid are then printed.
Private Sub DataGrid1_MouseDown(ByVal sender As Object, ByVal e As MouseEventArgs) Console.WriteLine() Dim myHitTest As DataGrid.HitTestInfo ' Use the DataGrid control's HitTest method with the x and y properties. myHitTest = DataGrid1.HitTest(e.X, e.Y) Console.WriteLine("Column " & myHitTest.Column) Console.WriteLine("Row " & myHitTest.Row) Console.WriteLine("Type " & myHitTest.Type) Console.WriteLine("ToString " & myHitTest.ToString) Console.WriteLine("Format " & myHitTest.Type.ToString) End Sub
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.