DataGrid.HitTestInfo.Type Property
Gets the part of the System.Windows.Forms.DataGrid control, other than the row or column, that was clicked.
[Visual Basic] Public ReadOnly Property Type As DataGrid.HitTestType [C#] public DataGrid.HitTestType Type {get;} [C++] public: __property DataGrid.HitTestType get_Type(); [JScript] public function get Type() : DataGrid.HitTestType;
Property Value
One of the DataGrid.HitTestType enumerations.
Example
[Visual Basic, C#, C++] 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.
[Visual Basic] Protected Sub dataGrid1_MouseDown(sender As Object, 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(("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 [C#] protected 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"; } } [C++] protected: void dataGrid1_MouseDown(Object* /*sender*/, System::Windows::Forms::MouseEventArgs* e) { String* newLine = S"\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(S"Hit {0}", 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 S"Cell"; case(System::Windows::Forms::DataGrid::HitTestType::Caption): return S"Caption"; case(System::Windows::Forms::DataGrid::HitTestType::ColumnHeader): return S"ColumnHeader"; case(System::Windows::Forms::DataGrid::HitTestType::ColumnResize): return S"Resize"; case(System::Windows::Forms::DataGrid::HitTestType::ParentRows): return S"ParentRows"; case(System::Windows::Forms::DataGrid::HitTestType::RowHeader): return S"RowHeader"; case(System::Windows::Forms::DataGrid::HitTestType::RowResize): return S"RowResize"; case(System::Windows::Forms::DataGrid::HitTestType::None): return S"None"; default:return S"Unknown"; } }
[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button
in the upper-left corner of the page.
Requirements
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework
See Also
DataGrid.HitTestInfo Class | DataGrid.HitTestInfo Members | System.Windows.Forms Namespace | DataGrid | DataGrid.HitTestType | HitTest