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

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

DataGridViewCellValueEventArgs.ColumnIndex プロパティ

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

イベント発生したセルの列インデックスを示す値を取得します

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

Dim instance As DataGridViewCellValueEventArgs
Dim value As Integer

value = instance.ColumnIndex
public int ColumnIndex { get;
 }
public:
property int ColumnIndex {
    int get ();
}
/** @property */
public int get_ColumnIndex ()

プロパティ
イベント発生したセルを含む列のインデックス

解説解説
使用例使用例

次のコード例は、ColumnIndex プロパティ使用してデータ ストアからセル値を取得する方法示してます。この例は 方法 : Windows フォーム DataGridView コントロール仮想モード実装する の例の一部です。

Private Sub dataGridView1_CellValueNeeded(ByVal
 sender As Object, _
    ByVal e As System.Windows.Forms.DataGridViewCellValueEventArgs)
 _
    Handles dataGridView1.CellValueNeeded

    ' If this is the row for new records, no values are needed.
    If e.RowIndex = Me.dataGridView1.RowCount
 - 1 Then
        Return
    End If

    Dim customerTmp As Customer = Nothing

    ' Store a reference to the Customer object for the row being painted.
    If e.RowIndex = rowInEdit Then
        customerTmp = Me.customerInEdit
    Else
        customerTmp = CType(Me.customers(e.RowIndex), Customer)
    End If

    ' Set the cell value to paint using the Customer object retrieved.
    Select Case Me.dataGridView1.Columns(e.ColumnIndex).Name
        Case "Company Name"
            e.Value = customerTmp.CompanyName

        Case "Contact Name"
            e.Value = customerTmp.ContactName
    End Select

End Sub
private void dataGridView1_CellValueNeeded(object
 sender,
    System.Windows.Forms.DataGridViewCellValueEventArgs e)
{
    // If this is the row for new records, no values are needed.
    if (e.RowIndex == this.dataGridView1.RowCount
 - 1) return;

    Customer customerTmp = null;

    // Store a reference to the Customer object for the row being painted.
    if (e.RowIndex == rowInEdit)
    {
        customerTmp = this.customerInEdit;
    }
    else 
    {
        customerTmp = (Customer)this.customers[e.RowIndex];
    }

    // Set the cell value to paint using the Customer object retrieved.
    switch (this.dataGridView1.Columns[e.ColumnIndex].Name)
    {
        case "Company Name":
            e.Value = customerTmp.CompanyName;
            break;

        case "Contact Name":
            e.Value = customerTmp.ContactName;
            break;
    }
}
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
DataGridViewCellValueEventArgs クラス
DataGridViewCellValueEventArgs メンバ
System.Windows.Forms 名前空間
DataGridView クラス
DataGridView.Columns プロパティ


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

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

辞書ショートカット

すべての辞書の索引

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

   

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



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

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

©2025 GRAS Group, Inc.RSS