DataGridCell.ColumnNumber Proprietà

Definizione

Ottiene o imposta il numero di una colonna nel controllo DataGrid.

public:
 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.

Esempio

Nell'esempio seguente viene assegnata la CurrentCell proprietà di un System.Windows.Forms.DataGrid oggetto a .DataGridCell Il valore archiviato nell'oggetto DataTable viene restituito specificando DataRow e DataColumn oggetti tramite le RowNumber proprietà e ColumnNumber .

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 ColumnNumber valore per specificare un DataColumn oggetto nell'oggetto DataTable associato al System.Windows.Forms.DataGrid controllo.

Si applica a

Vedi anche