DataGridCell DataGridCell DataGridCell DataGridCell Struct

定義

識別格線中的儲存格。Identifies a cell in the grid.

public value class DataGridCell
public struct DataGridCell
type DataGridCell = struct
Public Structure DataGridCell
繼承
DataGridCellDataGridCellDataGridCellDataGridCell

範例

下列範例會將指派DataGridCell CurrentCell給的System.Windows.Forms.DataGrid , 並傳回所選儲存格的資料行和資料列編號。The following example assigns the DataGridCell to the CurrentCell of a System.Windows.Forms.DataGrid and returns the column and row number of the selected cell. 儲存在中DataTable的值也會DataGridCell使用物件的RowNumberColumnNumber列印。The value stored in the DataTable is also printed using the DataGridCell object's RowNumber and 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

備註

可以與控制項的CurrentCell屬性搭配使用, 以取得或設定任何資料格的值。 System.Windows.Forms.DataGrid DataGridCellThe DataGridCell can be used in conjunction with the System.Windows.Forms.DataGrid control's CurrentCell property to get or set the value of any cell. 將控制項的CurrentCell屬性設定為DataGridCell , 會使焦點移至所DataGridCell指定的儲存格。 System.Windows.Forms.DataGridSetting the System.Windows.Forms.DataGrid control's CurrentCell property to a DataGridCell causes the focus to move to the cell specified by the DataGridCell.

建構函式

DataGridCell(Int32, Int32) DataGridCell(Int32, Int32) DataGridCell(Int32, Int32) DataGridCell(Int32, Int32)

初始化 DataGridCell 類別的新執行個體。Initializes a new instance of the DataGridCell class.

屬性

ColumnNumber ColumnNumber ColumnNumber ColumnNumber

取得或設定 DataGrid 控制項中的資料行編號。Gets or sets the number of a column in the DataGrid control.

RowNumber RowNumber RowNumber RowNumber

取得或設定 DataGrid 控制項中的資料列編號。Gets or sets the number of a row in the DataGrid control.

方法

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

取得值,表示 DataGridCell 是否與第二個 DataGridCell 相同。Gets a value indicating whether the DataGridCell is identical to a second DataGridCell.

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

取得可加入 Hashtable 的雜湊值。Gets a hash value that can be added to a Hashtable.

ToString() ToString() ToString() ToString()

取得儲存格的資料列編號和資料行編號。Gets the row number and column number of the cell.

適用於

另請參閱