Редагувати

Поділитися через


DataGrid.HitTestInfo Class

Definition

Contains information about a part of the DataGrid at a specified coordinate. This class cannot be inherited.

public: ref class DataGrid::HitTestInfo sealed
public sealed class DataGrid.HitTestInfo
type DataGrid.HitTestInfo = class
Public NotInheritable Class DataGrid.HitTestInfo
Inheritance
DataGrid.HitTestInfo

Examples

The following example uses the HitTest method in a MouseDown event to return the DataGrid.HitTestInfo object. The row, column, and part of the grid are then printed.

private:
   void dataGrid1_MouseDown( Object^ /*sender*/, System::Windows::Forms::MouseEventArgs^ e )
   {
      Console::WriteLine();
      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( myHitTest );
      Console::WriteLine( "Column {0}", myHitTest->Column );
      Console::WriteLine( "Row {0}", myHitTest->Row );
      Console::WriteLine( "Type {0}", myHitTest->Type );
      Console::WriteLine( "ToString {0}", myHitTest );
      Console::WriteLine( "Hit {0}", myHitTest->Type );
   }
private void dataGrid1_MouseDown
(object sender, System.Windows.Forms.MouseEventArgs e)
{
   Console.WriteLine();
   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(myHitTest);
   Console.WriteLine("Column " + myHitTest.Column);
   Console.WriteLine("Row " + myHitTest.Row);
   Console.WriteLine("Type " + myHitTest.Type);
   Console.WriteLine("ToString " + myHitTest.ToString());
   Console.WriteLine("Hit " + myHitTest.Type.ToString());
}
Private Sub DataGrid1_MouseDown(ByVal sender As Object, ByVal e As MouseEventArgs)
    Console.WriteLine()
    Dim myHitTest As DataGrid.HitTestInfo
    ' Use the DataGrid control's HitTest method with the x and y properties.
    myHitTest = DataGrid1.HitTest(e.X, e.Y)
    Console.WriteLine("Column " & myHitTest.Column)
    Console.WriteLine("Row " & myHitTest.Row)
    Console.WriteLine("Type " & myHitTest.Type)
    Console.WriteLine("ToString " & myHitTest.ToString)
    Console.WriteLine("Format " & myHitTest.Type.ToString)
End Sub

Remarks

The DataGrid.HitTestInfo class, in conjunction with the HitTest method of the DataGrid control, is used to determine which part of a DataGrid control the user has clicked. The DataGrid.HitTestInfo class contains the row, column, and part of the grid that was clicked. See the DataGrid.HitTestType enumeration returned by the Type property for a complete list of grid parts.

To return a DataGrid.HitTestInfo, invoke the HitTest method from the MouseDown event of DataGrid control. Pass the x and y properties of the MouseEventArgs to the HitTest method.

Fields

Nowhere

Indicates that a coordinate corresponds to part of the DataGrid control that is not functioning.

Properties

Column

Gets the number of the column the user has clicked.

Row

Gets the number of the row the user has clicked.

Type

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

Methods

Equals(Object)

Indicates whether two objects are identical.

GetHashCode()

Gets the hash code for the DataGrid.HitTestInfo instance.

GetType()

Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
ToString()

Gets the type, row number, and column number.

Applies to

See also