DataGrid.IsSelected(Int32) Método

Definição

Obtém um valor que indica se a linha especificada está selecionada.

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

Parâmetros

row
Int32

O número da linha em que você está interessado.

Retornos

Boolean

true se a linha estiver selecionada; caso contrário, false.

Exemplos

O exemplo de código a seguir demonstra o uso desse membro.

   // 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

Comentários

Use esse método com o Selectmétodo e UnSelectResetSelection os métodos para manipular o estado de seleção de uma linha específica.

Aplica-se a