DataGridCell Struktura

Definicja

Identyfikuje komórkę w siatce.

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

Przykłady

Poniższy przykład przypisuje element DataGridCell do CurrentCell obiektu System.Windows.Forms.DataGrid i zwraca kolumnę i numer wiersza wybranej komórki. Wartość przechowywana w obiekcie DataTable jest również drukowana przy użyciu DataGridCell obiektów RowNumber i 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

Uwagi

Można DataGridCell go użyć w połączeniu z właściwością System.Windows.Forms.DataGrid kontrolki CurrentCell , aby uzyskać lub ustawić wartość dowolnej komórki. System.Windows.Forms.DataGrid Ustawienie właściwości kontrolki CurrentCell na wartość DataGridCell powoduje przeniesienie fokusu do komórki określonej przez DataGridCellobiekt .

Konstruktory

DataGridCell(Int32, Int32)

Inicjuje nowe wystąpienie klasy DataGridCell.

Właściwości

ColumnNumber

Pobiera lub ustawia liczbę kolumn w kontrolce DataGrid .

RowNumber

Pobiera lub ustawia liczbę wierszy w kontrolce DataGrid .

Metody

Equals(Object)

Pobiera wartość wskazującą, czy DataGridCell wartość jest identyczna z sekundą DataGridCell.

GetHashCode()

Pobiera wartość skrótu, którą można dodać do elementu Hashtable.

ToString()

Pobiera numer wiersza i numer kolumny komórki.

Dotyczy

Zobacz też