DataGridCell.ColumnNumber DataGridCell.ColumnNumber DataGridCell.ColumnNumber DataGridCell.ColumnNumber Property


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

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

Valore della proprietà

Il numero della colonna.The number of the column.


Nell'esempio seguente viene assegnata CurrentCell la proprietà di System.Windows.Forms.DataGrid un oggetto DataGridCella un oggetto.The following example assigns the CurrentCell property of a System.Windows.Forms.DataGrid to a DataGridCell. Il valore DataTable archiviato in viene restituito specificando DataRow gli oggetti DataColumn e tramite le RowNumber proprietà ColumnNumber e.The value stored in the DataTable is returned by specifying DataRow and DataColumn objects through the 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]);

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)
End Sub


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

Si applica a

Vedi anche