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

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

DataGridView.CurrentCell プロパティ

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

現在アクティブセル取得または設定します

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

Dim instance As DataGridView
Dim value As DataGridViewCell

value = instance.CurrentCell

instance.CurrentCell = value
public DataGridViewCell CurrentCell { get;
 set; }
public:
property DataGridViewCell^ CurrentCell {
    DataGridViewCell^ get ();
    void set (DataGridViewCell^ value);
}
/** @property */
public DataGridViewCell get_CurrentCell ()

/** @property */
public void set_CurrentCell (DataGridViewCell
 value)
public function get CurrentCell
 () : DataGridViewCell

public function set CurrentCell
 (value : DataGridViewCell)

プロパティ
現在のセルを表す DataGridViewCell。現在のセルない場合null 参照 (Visual Basic では Nothing)。既定では 1 列目の最初セルになり、コントロールセル存在しない場合null 参照 (Visual Basic では Nothing) になります

例外例外
例外種類条件

InvalidOperationException

現在のセルへの変更コミットまたはキャンセルすることはできないため、このプロパティの値は設定できません。

または

このプロパティ設定時に指定されセルは、非表示の行または列にあります

ArgumentException

このプロパティ設定時に指定されセルが DataGridView にありません。

解説解説

セル現在のセルとして設定されていて、現在表示されていない場合は、スクロールして表示しますヘッダー セル無効なセル、非表示の行/列に存在するセル現在のセルになることはできません。

このプロパティnull 参照 (Visual Basic では Nothing) に設定することにより、一時的にフォーカス四角形削除できます。ただし、コントロールが再びフォーカス受け取ったときに、このプロパティの値が null 参照 (Visual Basic では Nothing) であることがわかると、自動的に FirstDisplayedCell プロパティの値に設定されます。

このプロパティの値を変更すると、CurrentCellChanged イベント前に、SelectionChanged イベント発生します。このとき、CurrentCell プロパティアクセスするすべての SelectionChanged イベント ハンドラには、変更前の値が渡されます。

DataGridView外部データ ソースバインドした場合、このプロパティはその既定値リセットされます。

使用例使用例

現在のセル並べ替えの後に表示されるようにするコード例次に示します。このコードは、バインドされていない DataGridView コントロールでだけ使用できます外部データ ソースバインドされた DataGridView コントロール場合現在のセルは、並べ替え時に自動的に永続化されません。

この例を実行するには、dataGridView1 という名前の DataGridView配置されているフォームに、次のコード貼り付けます。C# では、Sorted イベントイベント ハンドラ関連付ける必要もあります

Private Sub dataGridView1_Sorted(ByVal
 sender As Object, _
    ByVal e As System.EventArgs) Handles
 dataGridView1.Sorted

    Me.dataGridView1.FirstDisplayedCell = Me.dataGridView1.CurrentCell

End Sub
private void dataGridView1_Sorted(object sender,
 EventArgs e)
{
    this.dataGridView1.FirstDisplayedCell = this.dataGridView1.CurrentCell;
}
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
DataGridView クラス
DataGridView メンバ
System.Windows.Forms 名前空間
CurrentRow
SelectionChanged
CurrentCellChanged
FirstDisplayedCell
その他の技術情報
DataGridView コントロール (Windows フォーム)


このページでは「.NET Framework クラス ライブラリ リファレンス」からDataGridView.CurrentCell プロパティを検索した結果を表示しています。
Weblioに収録されているすべての辞書からDataGridView.CurrentCell プロパティを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からDataGridView.CurrentCell プロパティを検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

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

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

   

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



DataGridView.CurrentCell プロパティのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2024 GRAS Group, Inc.RSS