DataGridCell Estrutura
Importante
Algumas informações se referem a produtos de pré-lançamento que podem ser substancialmente modificados antes do lançamento. A Microsoft não oferece garantias, expressas ou implícitas, das informações aqui fornecidas.
Identifica uma célula na grade.
public value class DataGridCell
public struct DataGridCell
type DataGridCell = struct
Public Structure DataGridCell
- Herança
O exemplo a seguir atribui a DataGridCell CurrentCell de um System.Windows.Forms.DataGrid e retorna o número de coluna e linha da célula selecionada. O valor armazenado no DataTable também é impresso usando o DataGridCell objeto RowNumber e 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
O DataGridCell pode ser usado em conjunto com a System.Windows.Forms.DataGrid propriedade do CurrentCell controle para obter ou definir o valor de qualquer célula. Definir a System.Windows.Forms.DataGrid propriedade do CurrentCell controle como um DataGridCell faz com que o foco se mova para a célula especificada pelo DataGridCell.
Data |
Inicializa uma nova instância da classe DataGridCell. |
Column |
Obtém ou define o número de uma coluna no controle DataGrid. |
Row |
Obtém ou define o número de uma linha no controle DataGrid. |
Equals(Object) |
Obtém um valor que indica se o DataGridCell é idêntico a um segundo DataGridCell. |
Get |
Obtém um valor de hash que pode ser adicionado a um Hashtable. |
To |
Obtém o número da linha e o número da coluna da célula. |
Produto | Versões |
---|---|
.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 |
Windows Desktop | 3.0 |