Partilhar via


DataGridCell Estrutura

Definição

Cuidado

DataGrid is provided for binary compatibility with .NET Framework and is not intended to be used directly from your code. Use DataGridView instead.

Identifica uma célula na grade.

public value class DataGridCell
public struct DataGridCell
[System.ComponentModel.Browsable(false)]
[System.Obsolete("`DataGrid` is provided for binary compatibility with .NET Framework and is not intended to be used directly from your code. Use `DataGridView` instead.", false, DiagnosticId="WFDEV006", UrlFormat="https://aka.ms/winforms-warnings/{0}")]
public struct DataGridCell
type DataGridCell = struct
[<System.ComponentModel.Browsable(false)>]
[<System.Obsolete("`DataGrid` is provided for binary compatibility with .NET Framework and is not intended to be used directly from your code. Use `DataGridView` instead.", false, DiagnosticId="WFDEV006", UrlFormat="https://aka.ms/winforms-warnings/{0}")>]
type DataGridCell = struct
Public Structure DataGridCell
Herança
DataGridCell
Atributos

Exemplos

O exemplo a seguir atribui o DataGridCellCurrentCell 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

Comentários

Pode DataGridCell 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.

Construtores

Nome Description
DataGridCell(Int32, Int32)
Obsoleto.

Inicializa uma nova instância da classe DataGridCell.

Propriedades

Nome Description
ColumnNumber
Obsoleto.

Obtém ou define o número de uma coluna no DataGrid controle.

RowNumber
Obsoleto.

Obtém ou define o número de uma linha no DataGrid controle.

Métodos

Nome Description
Equals(Object)
Obsoleto.

Obtém um valor que indica se o DataGridCell é idêntico a um segundo DataGridCell.

GetHashCode()
Obsoleto.

Obtém um valor de hash que pode ser adicionado a um Hashtable.

ToString()
Obsoleto.

Obtém o número da linha e o número da coluna da célula.

Aplica-se a

Confira também