DataGrid.HitTestInfo DataGrid.HitTestInfo DataGrid.HitTestInfo DataGrid.HitTestInfo Class

定义

包含有关指定坐标处的 DataGrid 一部分的信息。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
继承
DataGrid.HitTestInfoDataGrid.HitTestInfoDataGrid.HitTestInfoDataGrid.HitTestInfo

示例

下面的示例使用HitTest MouseDown事件中的方法返回DataGrid.HitTestInfo对象。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

注解

类与DataGrid控件的HitTest方法一起用于确定用户已单击DataGrid控件中的哪个部分。 DataGrid.HitTestInfoThe 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. DataGrid.HitTestInfo类包含行、列和已单击的网格的一部分。The DataGrid.HitTestInfo class contains the row, column, and part of the grid that was clicked. 有关网格部分的完整列表Type , 请参阅属性返回的枚举。DataGrid.HitTestTypeSee the DataGrid.HitTestType enumeration returned by the Type property for a complete list of grid parts.

若要返回DataGrid.HitTestInfo, 请从HitTest DataGrid控件的MouseDown事件中调用方法。To return a DataGrid.HitTestInfo, invoke the HitTest method from the MouseDown event of DataGrid control. y将的xMouseEventArgs属性传递给方法。HitTestPass the x and y properties of the MouseEventArgs to the HitTest method.

字段

Nowhere Nowhere Nowhere Nowhere

指示某个坐标与 DataGrid 控件的未正常运行部分相对应。Indicates that a coordinate corresponds to part of the DataGrid control that is not functioning.

属性

Column Column Column Column

获取用户单击的列号。Gets the number of the column the user has clicked.

Row Row Row Row

获取用户单击的行号。Gets the number of the row the user has clicked.

Type Type Type Type

获取 DataGrid 控件中被单击的部分(不包括行或列)。Gets the part of the DataGrid control, other than the row or column, that was clicked.

方法

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

指示两个对象是否相同。Indicates whether two objects are identical.

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

获取 DataGrid.HitTestInfo 实例的哈希代码。Gets the hash code for the DataGrid.HitTestInfo instance.

GetType() GetType() GetType() GetType()

获取当前实例的 TypeGets the Type of the current instance.

(Inherited from Object)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(Inherited from Object)
ToString() ToString() ToString() ToString()

获取类型、行号和列号。Gets the type, row number, and column number.

适用于

另请参阅