DataGrid.CurrentRowIndex Propriété

Définition

Obtient ou définit l'index de la ligne qui a actuellement le focus.

public:
 property int CurrentRowIndex { int get(); void set(int value); };
[System.ComponentModel.Browsable(false)]
public int CurrentRowIndex { get; set; }
[<System.ComponentModel.Browsable(false)>]
member this.CurrentRowIndex : int with get, set
Public Property CurrentRowIndex As Integer

Valeur de propriété

Int32

Index de base zéro de la ligne active.

Attributs

Exceptions

Il n'existe pas de CurrencyManager.

Exemples

L’exemple de code suivant retourne le CurrentRowIndex.

private:
   void GetSelectedIndex( DataGrid^ myGrid )
   {
      Console::WriteLine( myGrid->CurrentRowIndex );
   }

   void SetSelectedIndex( DataGrid^ myGrid, int selIndex )
   {
      myGrid->CurrentRowIndex = selIndex;
   }
private void GetSelectedIndex(DataGrid myGrid){
    Console.WriteLine(myGrid.CurrentRowIndex);
 }
 
 private void SetSelectedIndex(DataGrid myGrid, int selIndex){
    myGrid.CurrentRowIndex = selIndex;
 }
Private Sub GetSelectedIndex(ByVal myGrid As DataGrid)
    Console.WriteLine(myGrid.CurrentRowIndex)
 End Sub
 
 Private Sub SetSelectedIndex(ByVal myGrid As DataGrid, ByVal selIndex As Integer)
    myGrid.CurrentRowIndex= selIndex
 End Sub

Remarques

La définition de la CurrentRowIndex propriété sur une valeur autre que sa valeur actuelle fait défiler le contrôle afin que la ligne spécifiée soit en mode.

La CurrentRowIndex propriété vous permet d’itérer dans les lignes d’une table parente même si vous affichez les lignes de table enfants. Par exemple, si vous affichez une table enfant, l’incrémentation CurrentRowIndex entraîne l’affichage System.Windows.Forms.DataGrid du jeu d’enregistrements suivant dans la table enfant liée à la table parente.

Si l’utilisateur affiche une table parente ou une table sans relation enfant, la propriété retourne l’index de base zéro de la ligne active.

S’applique à

Voir aussi