NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

DataGrid.HitTest (Int32, Int32)

Gets information, such as row and column number of a clicked point on the grid, using the x and y coordinate passed to the method.

[Visual Basic]
Overloads Public Function HitTest( _
   ByVal x As Integer, _
   ByVal y As Integer _
) As HitTestInfo
[C#]
public HitTestInfo HitTest(
   int x,
   int y
);
[C++]
public: HitTestInfo* HitTest(
   int x,
   int y
);
[JScript]
public function HitTest(
   x : int,
   y : int
) : HitTestInfo;

Parameters

x
The horizontal position of the coordinate.
y
The vertical position of the coordinate.

Return Value

A HitTestType that contains information about the portion of the grid the mouse has clicked.

Example [Visual Basic]

The following example uses the HitTest method in an event that occurs when the user clicks in the grid.

[Visual Basic]

Private Sub DataGrid1_MouseDown(ByVal s As Object, ByVal e As MouseEventArgs)
   Dim hti As [DataGrid.HitTestType]
   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

See Also

DataGrid Class | DataGrid Members | System.WinForms Namespace | DataGrid.HitTest Overload List | System.WinForms.Control.MouseDown