DataGrid.HitTestType Enumeration
This enumeration has a FlagsAttribute attribute that allows a bitwise combination of its member values.
Namespace: System.Windows.FormsAssembly: System.Windows.Forms (in system.windows.forms.dll)
| Member name | Description | |
|---|---|---|
| Caption | The caption of the System.Windows.Forms.DataGrid control. | |
![]() | Cell | A cell in the System.Windows.Forms.DataGrid control. |
![]() | ColumnHeader | A column header in the System.Windows.Forms.DataGrid control. |
![]() | ColumnResize | The column border, which is the line between column headers. It can be dragged to resize a column's width. |
![]() | None | The background area, visible when the control contains no table, few rows, or when a table is scrolled to its bottom. |
| ParentRows | The parent row section of the System.Windows.Forms.DataGrid control. The parent row displays information from or about the parent table of the currently displayed child table, such as the name of the parent table, column names and values of the parent record. | |
![]() | RowHeader | A row header in the System.Windows.Forms.DataGrid control. |
![]() | RowResize | The row border, which is the line between grid row headers. It can be dragged to resize a row's height. |
Use the members of this enumeration to determine which part of the grid has been clicked. The Type property of a DataGrid.HitTestInfo returns a DataGrid.HitTestType. The DataGrid.HitTestInfo is created by invoking the HitTest method of a System.Windows.Forms.DataGrid control.
The following example uses the HitTest method in a MouseDown event to return the DataGrid.HitTestInfo. The row, column, and part of the grid are then printed.
Private Sub dataGrid1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Dim newLine As String = ControlChars.Cr Console.WriteLine(newLine) Dim myHitTest As System.Windows.Forms.DataGrid.HitTestInfo ' Use the DataGrid control's HitTest method with the x and y properties. myHitTest = dataGrid1.HitTest(e.X, e.Y) Console.WriteLine(myHitTest) Console.WriteLine(("Column " & myHitTest.Column)) Console.WriteLine(("Row " & myHitTest.Row)) Console.WriteLine(("Type " & myHitTest.Type)) Console.WriteLine(("ToString " & myHitTest.ToString())) Console.WriteLine(("Hit " & ReturnHitTest(myHitTest.Type))) End Sub 'dataGrid1_MouseDown Private Function ReturnHitTest(hit As System.Windows.Forms.DataGrid.HitTestType) As String ' Use this function to return the part of the grid clicked. Select Case hit Case System.Windows.Forms.DataGrid.HitTestType.Cell Return "Cell" Case System.Windows.Forms.DataGrid.HitTestType.Caption Return "Caption" Case System.Windows.Forms.DataGrid.HitTestType.ColumnHeader Return "ColumnHeader" Case System.Windows.Forms.DataGrid.HitTestType.ColumnResize Return "Resize" Case System.Windows.Forms.DataGrid.HitTestType.ParentRows Return "ParentRows" Case System.Windows.Forms.DataGrid.HitTestType.RowHeader Return "RowHeader" Case System.Windows.Forms.DataGrid.HitTestType.RowResize Return "RowResize" Case System.Windows.Forms.DataGrid.HitTestType.None Return "None" Case Else Return "Unknown" End Select End Function 'ReturnHitTest
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.
