DataGrid.HitTestInfo.Type Property

Gets the part of the System.Windows.Forms.DataGrid control, other than the row or column, that was clicked.

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in system.windows.forms.dll)

public HitTestType Type { get; }
/** @property */
public HitTestType get_Type ()

public function get Type () : HitTestType

Property Value

One of the DataGrid.HitTestType enumerations.

The following example prints the clicked part of the grid by calling the HitTest method from within the MouseDown event of a System.Windows.Forms.DataGrid control. This returns a DataGrid.HitTestInfo object.

private void dataGrid1_MouseDown
(object sender, System.Windows.Forms.MouseEventArgs e)
{
   string newLine = "\n";
   Console.WriteLine(newLine);
   System.Windows.Forms.DataGrid.HitTestInfo myHitTest;
   // Use the DataGrid control's HitTest method with the x and y properties.
   myHitTest = dataGrid1.HitTest(e.X,e.Y);
   Console.WriteLine("Hit " + ReturnHitTest(myHitTest.Type ));
}
 
private string ReturnHitTest
(System.Windows.Forms.DataGrid.HitTestType hit)
{
   // Use this function to return the part of the grid clicked.   
   switch(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";

      default:return "Unknown";
   }
}
   

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.

.NET Framework

Supported in: 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0
Show: