DataGrid.IsSelected(Int32) メソッド

定義

指定した行が選択されているかどうかを示す値を取得します。Gets a value indicating whether a specified row is selected.

public:
 bool IsSelected(int row);
public bool IsSelected (int row);
member this.IsSelected : int -> bool
Public Function IsSelected (row As Integer) As Boolean

パラメーター

row
Int32

指定した行の番号。The number of the row you are interested in.

戻り値

Boolean

行が選択されている場合は true。それ以外の場合は falsetrue if the row is selected; otherwise, false.

このメンバーの使用例を次のコード例に示します。The following code example demonstrates the use of this member.

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

注釈

このメソッドを、、、およびの各メソッドと共に使用して、 Select UnSelect ResetSelection 特定の行の選択状態を操作します。Use this method with the Select, UnSelect, and ResetSelection methods to manipulate the selection state of a particular row.

適用対象