DataGridCell.RowNumber Eigenschaft

Definition

Ruft die Nummer einer Zeile im DataGrid-Steuerelement ab oder legt diese fest.

public:
 property int RowNumber { int get(); void set(int value); };
public int RowNumber { get; set; }
member this.RowNumber : int with get, set
Public Property RowNumber As Integer

Eigenschaftswert

Int32

Die Nummer der Zeile.

Beispiele

Im folgenden Beispiel wird die CurrentCell Eigenschaft eines System.Windows.Forms.DataGrid Objekts DataGridCell zugewiesen und der in den DataTable Eigenschaften des Objekts RowNumber ColumnNumber gespeicherte Wert zurückgegeben.

void PrintCell( Object^ sender, MouseEventArgs^ /*e*/ )
{
   DataGrid^ thisGrid = dynamic_cast<DataGrid^>(sender);
   DataGridCell myDataGridCell = thisGrid->CurrentCell;
   BindingManagerBase^ bm = BindingContext[ thisGrid->DataSource,thisGrid->DataMember ];
   DataRowView^ drv = dynamic_cast<DataRowView^>(bm->Current);
   Console::WriteLine( drv[ myDataGridCell.ColumnNumber ] );
   Console::WriteLine( myDataGridCell.RowNumber );
}
private void PrintCell(object sender, MouseEventArgs e)
{
   DataGrid thisGrid = (DataGrid) sender;
   DataGridCell myDataGridCell = thisGrid.CurrentCell;
   BindingManagerBase bm = BindingContext[thisGrid.DataSource, thisGrid.DataMember];
   DataRowView drv = (DataRowView) bm.Current;
   Console.WriteLine(drv [myDataGridCell.ColumnNumber]);
   Console.WriteLine(myDataGridCell.RowNumber);
}
Private Sub PrintCell(sender As Object, e As MouseEventArgs)
   Dim thisGrid As DataGrid = CType(sender, DataGrid)
   Dim myDataGridCell As DataGridCell = thisGrid.CurrentCell
   Dim bm As BindingManagerBase = _
   BindingContext (thisGrid.DataSource, thisGrid.DataMember)
   Dim drv As DataRowView = CType(bm.Current, DataRowView)
   Console.WriteLine(drv(myDataGridCell.ColumnNumber))
   Console.WriteLine(myDataGridCell.RowNumber)
End Sub

Hinweise

Sie können den RowNumber Wert verwenden, um einen DataRow Wert im DataTable zugeordneten System.Windows.Forms.DataGrid Steuerelement anzugeben.

Gilt für