Gets information, such as row and column number of a clicked point on the grid, about the grid using a specific Point.
[Visual Basic] Overloads Public Function HitTest( _ ByVal position As Point _ ) As HitTestInfo [C#] public HitTestInfo HitTest( Point position ); [C++] public: HitTestInfo* HitTest( Point position ); [JScript] public function HitTest( position : Point ) : HitTestInfo;
A DataGrid.HitTestInfo that contains specific information about the grid.
The following example uses the HitTest method in occurs when a user clicks on a grid.
[Visual Basic]
Private Sub DataGrid1_MouseDown(ByVal senderAs Object, ByVal e As EventArgs) Dim hti As [DataGrid.HitTestInfo] Set hti = grid.HitTest(e.X, e.Y) Select Case hti Case [DataGrid.HitTestType].None Console.WriteLine("You clicked nowhere.") Case.Type = [DataGrid.HitTestType].Cell Console.WriteLine("You clicked cell at row " & hti.Row & ", col " & hti.Column) Case [DataGrid.HitTestType].ColumnHeader Console.WriteLine("You clicked the column header for column " & hti.Column) Case [DataGrid.HitTestType].RowHeader Console.WriteLine("You clicked the row header for row " & hti.Row) Case [DataGrid.HitTestType].ColumnResize Console.WriteLine("You clicked the column resizer for column " & hti.Column) Case [DataGrid.HitTestType].RowResize Console.WriteLine("You clicked the row resizer for row " & hti.Row) Case [DataGrid.HitTestType].Caption Console.WriteLine("You clicked the caption") Case [DataGrid.HitTestType].ParentRows Console.WriteLine("You clicked the parent row") End If End Sub
DataGrid Class | DataGrid Members | System.WinForms Namespace | DataGrid.HitTest Overload List | System.WinForms.Control.MouseDown