Leer en inglés

Compartir a través de


DataGridCell.ColumnNumber Propiedad

Definición

Obtiene o establece el número de una columna del control DataGrid.

C#
public int ColumnNumber { get; set; }

Valor de propiedad

Número de la columna.

Ejemplos

En el ejemplo siguiente se asigna la CurrentCell propiedad de a System.Windows.Forms.DataGrid .DataGridCell El valor almacenado en DataTable se devuelve especificando DataRow objetos y DataColumn a través de las RowNumber propiedades y ColumnNumber .

C#
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);
}

Comentarios

Puede usar el ColumnNumber valor para especificar un DataColumn elemento en el DataTable asociado al System.Windows.Forms.DataGrid control .

Se aplica a

Producto Versiones
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 10

Consulte también