DataGridCell 構造体

定義

グリッド内のセルを識別します。

public value class DataGridCell
public struct DataGridCell
type DataGridCell = struct
Public Structure DataGridCell
継承
DataGridCell

次の例では、DataGridCella System.Windows.Forms.DataGrid のセルに代入CurrentCellし、選択したセルの列と行番号を返します。 に格納されているDataTable値は、オブジェクトRowNumberColumnNumber.DataGridCell

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 プロパティと System.Windows.Forms.DataGrid 組み合わせて使用して、任意の CurrentCell セルの値を取得または設定できます。 コントロールのCurrentCellプロパティを System.Windows.Forms.DataGrid a DataGridCell に設定すると、フォーカスが指定されたDataGridCellセルに移動します。

コンストラクター

DataGridCell(Int32, Int32)

DataGridCell クラスの新しいインスタンスを初期化します。

プロパティ

ColumnNumber

DataGrid コントロールの列の番号を取得または設定します。

RowNumber

DataGrid コントロールの行の番号を取得または設定します。

メソッド

Equals(Object)

DataGridCell が第 2 の DataGridCell と同一であるかどうかを示す値を取得します。

GetHashCode()

Hashtable に追加できるハッシュ値を取得します。

ToString()

セルの行番号と列番号を取得します。

適用対象

こちらもご覧ください