CodePanic! > C#.NET Tips > 今ここ■カレントセルを取得、設定するDataGridViewの現在選択中のカレントセルを取得、設定するには CurrentCellプロパティーを利用します。
// カレントセルの値を参照
dataGridView1.CurrentCell.Value; // 値
dataGridView1.CurrentCell.RowIndex; // 行
dataGridView1.CurrentCell.ColumnIndex; // 列
dataGridView1.CurrentCell.ReadOnly; // 読み取り専用か否か
// カレントセルを変更
dataGridView1.CurrentCell = dataGridView1[0, 0];
|