DataGridCell Estructura

Definición

Identifica una celda de la cuadrícula.

public value class DataGridCell
public struct DataGridCell
type DataGridCell = struct
Public Structure DataGridCell
Herencia
DataGridCell

Ejemplos

En el ejemplo siguiente se asigna a DataGridCell de CurrentCell y System.Windows.Forms.DataGrid se devuelve la columna y el número de fila de la celda seleccionada. El valor almacenado en DataTable también se imprime mediante el DataGridCell objeto RowNumber y ColumnNumber.

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 = dynamic_cast<DataTable^>(DataGrid1->DataSource);
   Console::WriteLine( myTable->Rows[ myCell->RowNumber ][ myCell->ColumnNumber ] );
}
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 Sub PrintCellRowAndCol()
    Dim myCell As DataGridCell
    myCell = DataGrid1.CurrentCell
    Console.WriteLine(myCell.RowNumber)
    Console.WriteLine(myCell.ColumnNumber)
    ' Prints the value of the cell through the DataTable.
    Dim myTable As DataTable
    ' Assumes the DataGrid is bound to a DataTable.
    myTable = CType(DataGrid1.DataSource, DataTable)
    Console.WriteLine(myTable.Rows(myCell.RowNumber)(myCell.ColumnNumber))
 End Sub

Comentarios

DataGridCell Se puede usar junto con la System.Windows.Forms.DataGrid propiedad del CurrentCell control para obtener o establecer el valor de cualquier celda. Al establecer la System.Windows.Forms.DataGrid propiedad del CurrentCell control en , DataGridCell el foco se mueve a la celda especificada por .DataGridCell

Constructores

DataGridCell(Int32, Int32)

Inicializa una nueva instancia de la clase DataGridCell.

Propiedades

ColumnNumber

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

RowNumber

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

Métodos

Equals(Object)

Obtiene un valor que indica si DataGridCell es idéntico a un segundo DataGridCell.

GetHashCode()

Obtiene un valor hash que puede agregarse a un Hashtable.

ToString()

Obtiene el número de fila y el número de columna de la celda.

Se aplica a

Consulte también