DataGrid.HitTestInfo.Row プロパティ
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)


座標がセルの外部にある場合、このプロパティは -1 を返します。座標が RowHeader を示している場合、このプロパティはヘッダーの行番号を返しますが、Column プロパティは -1 を返します。

System.Windows.Forms.DataGrid コントロールの MouseDown イベント内から HitTest メソッドを呼び出すことにより、クリックされた行と列の番号を出力する例を次に示します。この例では、DataGrid.HitTestInfo オブジェクトが返されます。
Private Sub dataGrid1_MouseDown(ByVal sender As Object, ByVal 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(("Column " & myHitTest.Column)) Console.WriteLine(("Row " & myHitTest.Row)) End Sub 'dataGrid1_MouseDown
private 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("Column " + myHitTest.Column); Console.WriteLine("Row " + myHitTest.Row); }
private: 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( "Column {0}", myHitTest->Column ); Console::WriteLine( "Row {0}", myHitTest->Row ); }

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


Weblioに収録されているすべての辞書からDataGrid.HitTestInfo.Row プロパティを検索する場合は、下記のリンクをクリックしてください。

- DataGrid.HitTestInfo.Row プロパティのページへのリンク