DataGridCellとは? わかりやすく解説

DataGridCell コンストラクタ

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

名前空間: System.Windows.Forms
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文構文

Dim r As Integer
Dim c As Integer

Dim instance As New DataGridCell(r,
 c)
public DataGridCell (
    int r,
    int c
)
public:
DataGridCell (
    int r, 
    int c
)
public DataGridCell (
    int r, 
    int c
)
public function DataGridCell (
    r : int, 
    c : int
)

パラメータ

r

System.Windows.Forms.DataGrid の行の番号。

c

System.Windows.Forms.DataGrid の列の番号。

使用例使用例

DataGridCell を作成し、その新しいインスタンスを System.Windows.Forms.DataGrid コントロールの CurrentCell に設定する例を次に示します。

Private Sub SetCell()
   ' Set the focus to the cell specified by the DataGridCell.
   Dim dc As DataGridCell
   dc.RowNumber = 1
   dc.ColumnNumber = 1
   DataGrid1.CurrentCell = dc
End Sub

private void SetCell()
{
   // Set the focus to the cell specified by the DataGridCell.
   DataGridCell dc = new DataGridCell();
   dc.RowNumber = 1;
   dc.ColumnNumber = 1;
   dataGrid1.CurrentCell = dc;
}

private:
   void SetCell()
   {
      // Set the focus to the cell specified by the DataGridCell.
      DataGridCell dc;
      dc.RowNumber = 1;
      dc.ColumnNumber = 1;
      dataGrid1->CurrentCell = dc;
   }
private void SetCell()
{
    // Set the focus to the cell specified by the DataGridCell.
    DataGridCell dc = new DataGridCell();
    dc.set_RowNumber(1);
    dc.set_ColumnNumber(1);
    dataGrid1.set_CurrentCell(dc);
} //SetCell
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
DataGridCell 構造体
DataGridCell メンバ
System.Windows.Forms 名前空間
DataGrid.CurrentCell プロパティ
DataColumn
DataGrid クラス
DataRow
ColumnNumber
RowNumber

DataGridCell プロパティ


パブリック プロパティパブリック プロパティ

  名前 説明
パブリック プロパティ RowNumber System.Windows.Forms.DataGrid コントロールの行の番号を取得または設定します。
参照参照

関連項目

DataGridCell 構造体
System.Windows.Forms 名前空間
DataGrid.CurrentCell プロパティ
DataColumn
DataGrid クラス
DataRow
ColumnNumber
RowNumber

DataGridCell メソッド


DataGridCell メンバ

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

DataGridCell データ型で公開されるメンバを以下の表に示します。


パブリック コンストラクタパブリック コンストラクタ
  名前 説明
パブリック メソッド DataGridCell DataGridCell クラスの新しいインスタンスを初期化します。
パブリック プロパティパブリック プロパティ
  名前 説明
パブリック プロパティ RowNumber System.Windows.Forms.DataGrid コントロールの行の番号を取得または設定します。
パブリック メソッドパブリック メソッド
プロテクト メソッドプロテクト メソッド
参照参照

関連項目

DataGridCell 構造体
System.Windows.Forms 名前空間
DataGrid.CurrentCell プロパティ
DataColumn
DataGrid クラス
DataRow
ColumnNumber
RowNumber

DataGridCell 構造体

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

名前空間: System.Windows.Forms
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文構文

public struct DataGridCell
public value class DataGridCell
public final class DataGridCell extends ValueType
JScript では、構造体を使用できますが、新規に宣言することはできません。
解説解説

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

使用例使用例

DataGridCell を System.Windows.Forms.DataGrid の CurrentCell に割り当て、選択したセルの列番号と行番号を返す例を次に示します。DataTable に格納されている値も、DataGridCell オブジェクトの RowNumber と 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

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]);
}

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.get_CurrentCell();
    Console.WriteLine(myCell.get_RowNumber());
    Console.WriteLine(myCell.get_ColumnNumber());
    // Prints the value of the cell through the DataTable.
    DataTable myTable;
    // Assumes the DataGrid is bound to a DataTable.
    myTable = (DataTable)(dataGrid1.get_DataSource());
    Console.WriteLine(myTable.get_Rows().
        get_Item(myCell.get_RowNumber()).
        get_Item(myCell.get_ColumnNumber()));
} //PrintCellRowAndCol
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバの場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
DataGridCell メンバ
System.Windows.Forms 名前空間
DataGrid.CurrentCell プロパティ
DataColumn
DataGrid クラス
DataRow
ColumnNumber
RowNumber



英和和英テキスト翻訳

英語⇒日本語日本語⇒英語

辞書ショートカット

すべての辞書の索引

「DataGridCell」の関連用語

DataGridCellのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



DataGridCellのページの著作権

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2026 Microsoft.All rights reserved.

©2026 GRAS Group, Inc.RSS