通过


DataGridCell 结构

定义

注意

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

标识网格中的单元格。

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
继承
DataGridCell
属性

示例

以下示例将赋 DataGridCellCurrentCell 所选 System.Windows.Forms.DataGrid 单元格的列和行号,并返回所选单元格的列和行号。 存储在该 DataTable 对象中的值也使用 DataGridCell 对象的 RowNumberColumnNumber

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

注解

DataGridCell可与控件CurrentCell的属性结合使用System.Windows.Forms.DataGrid来获取或设置任何单元格的值。 将 System.Windows.Forms.DataGrid 控件 CurrentCell 的属性设置为使 DataGridCell 焦点移动到由该控件 DataGridCell指定的单元格。

构造函数

名称 说明
DataGridCell(Int32, Int32)
已过时.

初始化 DataGridCell 类的新实例。

属性

名称 说明
ColumnNumber
已过时.

获取或设置控件中的 DataGrid 列数。

RowNumber
已过时.

获取或设置控件中的 DataGrid 行数。

方法

名称 说明
Equals(Object)
已过时.

获取一个值,该值指示这 DataGridCell 是否与第二 DataGridCell个值相同。

GetHashCode()
已过时.

获取可添加到 的 Hashtable哈希值。

ToString()
已过时.

获取单元格的行号和列号。

适用于

另请参阅