Bagikan melalui


DataGridCell Struktur

Definisi

Perhatian

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

Mengidentifikasi sel di kisi.

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
Warisan
DataGridCell
Atribut

Contoh

Contoh berikut menetapkan DataGridCell ke CurrentCell dari dan System.Windows.Forms.DataGrid mengembalikan nomor kolom dan baris dari sel yang dipilih. Nilai yang DataTable disimpan dalam juga dicetak menggunakan DataGridCell objek RowNumber dan 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

Keterangan

DataGridCell dapat digunakan bersama dengan System.Windows.Forms.DataGrid properti kontrol CurrentCell untuk mendapatkan atau mengatur nilai sel apa pun. System.Windows.Forms.DataGrid Mengatur properti kontrol CurrentCell ke DataGridCell penyebab fokus berpindah ke sel yang ditentukan oleh DataGridCell.

Konstruktor

Nama Deskripsi
DataGridCell(Int32, Int32)
Kedaluwarsa.

Menginisialisasi instans baru dari kelas DataGridCell.

Properti

Nama Deskripsi
ColumnNumber
Kedaluwarsa.

Mendapatkan atau mengatur jumlah kolom dalam DataGrid kontrol.

RowNumber
Kedaluwarsa.

Mendapatkan atau mengatur jumlah baris dalam DataGrid kontrol.

Metode

Nama Deskripsi
Equals(Object)
Kedaluwarsa.

Mendapatkan nilai yang menunjukkan apakah DataGridCell identik dengan detik DataGridCell.

GetHashCode()
Kedaluwarsa.

Mendapatkan nilai hash yang dapat ditambahkan ke Hashtable.

ToString()
Kedaluwarsa.

Mendapatkan nomor baris dan nomor kolom sel.

Berlaku untuk

Lihat juga