DataGrid.HitTestInfo.Row 속성

정의

사용자가 클릭한 행의 번호를 가져옵니다.

public:
 property int Row { int get(); };
public int Row { get; }
member this.Row : int
Public ReadOnly Property Row As Integer

속성 값

클릭한 행의 번호입니다.

예제

호출 하 여 클릭 한 행 및 열 번호를 인쇄 하는 다음 예제에서는 합니다 HitTest 메서드 내에서 MouseDown 이벤트를 System.Windows.Forms.DataGrid 컨트롤. 반환 된 DataGrid.HitTestInfo 개체입니다.

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 );
   }
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 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

설명

에 대 한 좌표를 없는 경우 셀 속성-1을 반환 합니다. 좌표는 경우는 RowHeader, 속성 헤더의 행 수를 반환 합니다. 하지만 Column 속성은-1을 반환 합니다.

적용 대상

추가 정보