다음을 통해 공유


DataGrid.Select(Int32) 메서드

정의

지정된 행을 선택합니다.

public:
 void Select(int row);
public void Select (int row);
override this.Select : int -> unit
Public Sub Select (row As Integer)

매개 변수

row
Int32

선택할 행의 인덱스입니다.

예제

다음 코드 예제에서는이 멤버를 사용 하는 방법을 보여 줍니다.

   // Select the first row.
private:
   void button7_Click( Object^ /*sender*/, EventArgs^ /*e*/ )
   {
      myDataGrid->Select(0);
   }

   // Check if the first row is selected.
private:
   void button8_Click( Object^ /*sender*/, EventArgs^ /*e*/ )
   {
      if ( myDataGrid->IsSelected( 0 ) )
      {
         MessageBox::Show( "Row selected", "Message", MessageBoxButtons::OK, MessageBoxIcon::Exclamation );
      }
      else
      {
         MessageBox::Show( "Row not selected", "Message", MessageBoxButtons::OK, MessageBoxIcon::Exclamation );
      }
   }

   // Deselect the first row.
   void button11_Click( Object^ /*sender*/, EventArgs^ /*e*/ )
   {
      myDataGrid->UnSelect( 0 );
   }
// Select the first row.
private void button7_Click(object sender, EventArgs e)
{
   myDataGrid.Select(0);
}
// Check if the first row is selected.
private void button8_Click(object sender, EventArgs e)
{         
   if(myDataGrid.IsSelected(0))
   {
      MessageBox.Show("Row selected",
         "Message",   MessageBoxButtons.OK,
         MessageBoxIcon.Exclamation);
   }
   else
   {
      MessageBox.Show("Row not selected",
         "Message",   MessageBoxButtons.OK,
         MessageBoxIcon.Exclamation);
   }         
}
// Deselect the first row.
private void button11_Click(object sender, EventArgs e)
{
   myDataGrid.UnSelect(0);
}
' Select the first row.
Private Sub button7_Click(ByVal sender As Object, ByVal e As EventArgs) Handles button7.Click
    myDataGrid.Select(0)
End Sub

' Check if the first row is selected.
Private Sub button8_Click(ByVal sender As Object, ByVal e As EventArgs) Handles button8.Click
    If myDataGrid.IsSelected(0) Then
        MessageBox.Show("Row selected", "Message", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
    Else
        MessageBox.Show("Row not selected", "Message", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
    End If
End Sub

' Deselect the first row.
Private Sub button11_Click(ByVal sender As Object, ByVal e As EventArgs) Handles button11.Click
    myDataGrid.UnSelect(0)
End Sub

설명

이 메서드를 IsSelected, UnSelect및 메서드와 ResetSelection 함께 사용하여 특정 행의 선택 상태를 조작합니다.

적용 대상