DataGrid.HitTestInfo クラス
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)


DataGrid.HitTestInfo クラスは、DataGrid コントロール内のどの部分をユーザーがクリックしたかを判断するために、DataGrid コントロールの HitTest メソッドと組み合わせて使用されます。DataGrid.HitTestInfo クラスには、行、列、およびグリッド内のクリックされた部分に関する情報が格納されます。グリッドの各部の詳細については、Type プロパティで返される DataGrid.HitTestType 列挙値を参照してください。
DataGrid.HitTestInfo を返すには、DataGrid コントロールの MouseDown イベントから HitTest メソッドを呼び出します。その際、MouseEventArgs の x プロパティと y プロパティを HitTest メソッドに渡します。

MouseDown イベントで HitTest メソッドを呼び出し、DataGrid.HitTestInfo オブジェクトを返す例を次に示します。行、列、およびグリッドの部分に関する情報が出力されます。
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
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: 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 ); }

System.Windows.Forms.DataGrid.HitTestInfo


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
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


DataGrid.HitTestInfo メンバ
System.Windows.Forms 名前空間
DataGrid.CurrentCell プロパティ
GetCellBounds
HitTest
DataGrid.HitTestType
- DataGrid.HitTestInfo クラスのページへのリンク