DataGridCell (Estructura)
Actualización: noviembre 2007
Identifica una celda de la cuadrícula.
Ensamblado: System.Windows.Forms (en System.Windows.Forms.dll)
DataGridCell puede utilizarse junto con la propiedad CurrentCell del control System.Windows.Forms.DataGrid para obtener o establecer el valor de cualquier celda. El establecimiento de la propiedad CurrentCell del control System.Windows.Forms.DataGrid en DataGridCell hace que el foco se mueva a la celda especificada por DataGridCell.
En el ejemplo siguiente se asigna DataGridCell a la propiedad CurrentCell de System.Windows.Forms.DataGrid y se devuelve el número de columna y fila de la celda seleccionada. El valor almacenado en DataTable se imprime también mediante el uso de las propiedades RowNumber y ColumnNumber del objeto DataGridCell.
private void PrintCellRowAndCol() { DataGridCell myCell; myCell = DataGrid1.CurrentCell; Console.WriteLine(myCell.RowNumber); Console.WriteLine(myCell.ColumnNumber); // Prints the value of the cell through the DataTable. DataTable myTable; // Assumes the DataGrid is bound to a DataTable. myTable = (DataTable) DataGrid1.DataSource; Console.WriteLine(myTable.Rows[myCell.RowNumber] [myCell.ColumnNumber]); }
private void PrintCellRowAndCol()
{
DataGridCell myCell;
myCell = dataGrid1.get_CurrentCell();
Console.WriteLine(myCell.get_RowNumber());
Console.WriteLine(myCell.get_ColumnNumber());
// Prints the value of the cell through the DataTable.
DataTable myTable;
// Assumes the DataGrid is bound to a DataTable.
myTable = (DataTable)(dataGrid1.get_DataSource());
Console.WriteLine(myTable.get_Rows().
get_Item(myCell.get_RowNumber()).
get_Item(myCell.get_ColumnNumber()));
} //PrintCellRowAndCol
Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98, Windows CE, Windows Mobile para Smartphone, Windows Mobile para Pocket PC
.NET Framework y .NET Compact Framework no admiten todas las versiones de cada plataforma. Para obtener una lista de las versiones compatibles, vea Requisitos de sistema de .NET Framework.