DataGridCell.RowNumber DataGridCell.RowNumber DataGridCell.RowNumber DataGridCell.RowNumber Property

Definizione

Ottiene o imposta il numero di una riga nel controllo DataGrid.Gets or sets the number of a row in the DataGrid control.

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

Valore della proprietà

Numero della riga.The number of the row.

Esempi

Nell'esempio seguente viene assegnata CurrentCell la proprietà di System.Windows.Forms.DataGrid un DataTable oggetto DataGridCell a un oggetto e viene RowNumber restituito il valore archiviato nelle ColumnNumber proprietà e dell'oggetto.The following example assigns the CurrentCell property of a System.Windows.Forms.DataGrid to a DataGridCell and returns the value stored in the DataTable object's RowNumber and ColumnNumber properties.

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

Commenti

È possibile usare il RowNumber valore per specificare un DataRow oggetto System.Windows.Forms.DataGrid nell' DataTable oggetto associato al controllo.You can use the RowNumber value to specify a DataRow in the DataTable associated with the System.Windows.Forms.DataGrid control.

Si applica a