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

若要返回DataGrid.HitTestInfo,调用HitTest方法从MouseDown事件的DataGrid控件。To return a DataGrid.HitTestInfo, invoke the HitTest method from the MouseDown event of DataGrid control. 传递xy的属性MouseEventArgsHitTest方法。Pass 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.

适用于

另请参阅