DataGridCell Estructura

Definición

Identifica una celda de la cuadrícula.Identifies a cell in the grid.

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

Ejemplos

En el ejemplo siguiente DataGridCell se asigna a CurrentCell de y se System.Windows.Forms.DataGrid devuelve el número de columna y de fila de la celda seleccionada.The following example assigns the DataGridCell to the CurrentCell of a System.Windows.Forms.DataGrid and returns the column and row number of the selected cell. El valor almacenado en DataTable también se imprime utilizando el DataGridCell y el objeto RowNumber ColumnNumber .The value stored in the DataTable is also printed using the DataGridCell object's RowNumber and 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

DataGridCellSe puede usar junto con la System.Windows.Forms.DataGrid propiedad del control CurrentCell para obtener o establecer el valor de cualquier celda.The DataGridCell can be used in conjunction with the System.Windows.Forms.DataGrid control's CurrentCell property to get or set the value of any cell. Establecer la System.Windows.Forms.DataGrid propiedad del control CurrentCell en un DataGridCell hace que el foco se mueva a la celda especificada por DataGridCell .Setting the System.Windows.Forms.DataGrid control's CurrentCell property to a DataGridCell causes the focus to move to the cell specified by the DataGridCell.

Constructores

DataGridCell(Int32, Int32)

Inicializa una nueva instancia de la clase DataGridCell.Initializes a new instance of the DataGridCell class.

Propiedades

ColumnNumber

Obtiene o establece el número de una columna del control DataGrid.Gets or sets the number of a column in the DataGrid control.

RowNumber

Obtiene o establece el número de una fila del control DataGrid.Gets or sets the number of a row in the DataGrid control.

Métodos

Equals(Object)

Obtiene un valor que indica si DataGridCell es idéntico a un segundo DataGridCell.Gets a value indicating whether the DataGridCell is identical to a second DataGridCell.

GetHashCode()

Obtiene un valor hash que puede agregarse a un Hashtable.Gets a hash value that can be added to a Hashtable.

ToString()

Obtiene el número de fila y el número de columna de la celda.Gets the row number and column number of the cell.

Se aplica a

Consulte también