Condividi tramite


DataGridCell Struct

Definizione

Attenzione

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

Identifica una cella nella griglia.

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
Ereditarietà
DataGridCell
Attributi

Esempio

Nell'esempio seguente l'oggetto DataGridCell viene assegnato a CurrentCell di e System.Windows.Forms.DataGrid restituisce la colonna e il numero di riga della cella selezionata. Il valore archiviato in DataTable viene stampato anche utilizzando l'oggetto DataGridCellRowNumber 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

Commenti

Può DataGridCell essere utilizzato insieme alla System.Windows.Forms.DataGrid proprietà del CurrentCell controllo per ottenere o impostare il valore di qualsiasi cella. L'impostazione della System.Windows.Forms.DataGrid proprietà del CurrentCell controllo su un DataGridCell determina lo spostamento dello stato attivo nella cella specificata da DataGridCell.

Costruttori

Nome Descrizione
DataGridCell(Int32, Int32)
Obsoleti.

Inizializza una nuova istanza della classe DataGridCell.

Proprietà

Nome Descrizione
ColumnNumber
Obsoleti.

Ottiene o imposta il numero di una colonna nel DataGrid controllo .

RowNumber
Obsoleti.

Ottiene o imposta il numero di una riga nel DataGrid controllo .

Metodi

Nome Descrizione
Equals(Object)
Obsoleti.

Ottiene un valore che indica se l'oggetto DataGridCell è identico a un secondo DataGridCelloggetto .

GetHashCode()
Obsoleti.

Ottiene un valore hash che può essere aggiunto a un oggetto Hashtable.

ToString()
Obsoleti.

Ottiene il numero di riga e il numero di colonna della cella.

Si applica a

Vedi anche