DataGridView.CurrentCellAddress プロパティとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > DataGridView.CurrentCellAddress プロパティの意味・解説 

DataGridView.CurrentCellAddress プロパティ

メモ : このプロパティは、.NET Framework version 2.0 で新しく追加されたものです。

現在アクティブなセルの行インデックスおよび列インデックスを取得します。

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

Dim instance As DataGridView
Dim value As Point

value = instance.CurrentCellAddress
public Point CurrentCellAddress { get; }
public:
property Point CurrentCellAddress {
    Point get ();
}
/** @property */
public Point get_CurrentCellAddress ()
public function get CurrentCellAddress
 () : Point

プロパティ値
現在アクティブなセルの行インデックスおよび列インデックスを表す Point。

解説解説

セルに直接アクセスせずに現在のセルの行および列を確認するには、このプロパティを使用します。これは、共有行が非共有にならないようにする場合に便利です。行の共有の詳細については、「Windows フォーム DataGridView コントロールを拡張するための推奨される手順」を参照してください。

使用例使用例

行を描画するシナリオで CurrentCellAddress プロパティを使用する方法のコード例を次に示します。この例では、このプロパティは現在のセルの行インデックスを格納するために使用されます。ユーザーが現在のセルを別の行に変更すると、行は強制的に再描画されます。

ここに示すコードは、「方法 : Windows フォームの DataGridView コントロールの行の外観をカスタマイズする」で取り上げられているコードの一部です。

' Forces the row to repaint itself when the user changes the 
' current cell. This is necessary to refresh the focus rectangle.
Sub dataGridView1_CurrentCellChanged(ByVal
 sender As Object, _
    ByVal e As EventArgs) Handles
 dataGridView1.CurrentCellChanged

    If oldRowIndex <> -1 Then
        Me.dataGridView1.InvalidateRow(oldRowIndex)
    End If
    oldRowIndex = Me.dataGridView1.CurrentCellAddress.Y

End Sub 'dataGridView1_CurrentCellChanged
// Forces the row to repaint itself when the user changes the 
// current cell. This is necessary to refresh the focus rectangle.
void dataGridView1_CurrentCellChanged(object sender, EventArgs
 e)
{
    if (oldRowIndex != -1)
    {
        this.dataGridView1.InvalidateRow(oldRowIndex);
    }
    oldRowIndex = this.dataGridView1.CurrentCellAddress.Y;
}
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照



英和和英テキスト翻訳

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

辞書ショートカット

すべての辞書の索引

「DataGridView.CurrentCellAddress プロパティ」の関連用語

DataGridView.CurrentCellAddress プロパティのお隣キーワード
検索ランキング

   

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



DataGridView.CurrentCellAddress プロパティのページの著作権

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

©2026 GRAS Group, Inc.RSS