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

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

DataGridViewCellMouseEventArgs.ColumnIndex プロパティ

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

セルの 0 から始まる列インデックス取得します

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

Dim instance As DataGridViewCellMouseEventArgs
Dim value As Integer

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

プロパティ
インデックス指定する整数

使用例使用例

このプロパティ使用方法を示すコード例次に示します

Private Sub dataGridView1_ColumnHeaderMouseClick(ByVal
 sender As Object, _
    ByVal e As DataGridViewCellMouseEventArgs)
 _
    Handles dataGridView1.ColumnHeaderMouseClick

    Dim newColumn As DataGridViewColumn = _
        dataGridView1.Columns(e.ColumnIndex)
    Dim oldColumn As DataGridViewColumn = dataGridView1.SortedColumn
    Dim direction As ListSortDirection

    ' If oldColumn is null, then the DataGridView is not currently sorted.
    If Not oldColumn Is
 Nothing Then

        ' Sort the same column again, reversing the SortOrder.
        If oldColumn Is newColumn AndAlso
 dataGridView1.SortOrder = _
            SortOrder.Ascending Then
            direction = ListSortDirection.Descending
        Else

            ' Sort a new column and remove the old SortGlyph.
            direction = ListSortDirection.Ascending
            oldColumn.HeaderCell.SortGlyphDirection = SortOrder.None
        End If
    Else
        direction = ListSortDirection.Ascending
    End If

    ' Sort the selected column.
    dataGridView1.Sort(newColumn, direction)
    If direction = ListSortDirection.Ascending Then
        newColumn.HeaderCell.SortGlyphDirection = SortOrder.Ascending
    Else
        newColumn.HeaderCell.SortGlyphDirection = SortOrder.Descending
    End If

End Sub
private void dataGridView1_ColumnHeaderMouseClick(
    object sender, DataGridViewCellMouseEventArgs e)
{
    DataGridViewColumn newColumn = dataGridView1.Columns[e.ColumnIndex];
    DataGridViewColumn oldColumn = dataGridView1.SortedColumn;
    ListSortDirection direction;

    // If oldColumn is null, then the DataGridView is not sorted.
    if (oldColumn != null)
    {
        // Sort the same column again, reversing the SortOrder.
        if (oldColumn == newColumn &&
            dataGridView1.SortOrder == SortOrder.Ascending)
        {
            direction = ListSortDirection.Descending;
        }
        else
        {
            // Sort a new column and remove the old SortGlyph.
            direction = ListSortDirection.Ascending;
            oldColumn.HeaderCell.SortGlyphDirection = SortOrder.None;
        }
    }
    else
    {
        direction = ListSortDirection.Ascending;
    }

    // Sort the selected column.
    dataGridView1.Sort(newColumn, direction);
    newColumn.HeaderCell.SortGlyphDirection =
        direction == ListSortDirection.Ascending ?
        SortOrder.Ascending : SortOrder.Descending;
}
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
DataGridViewCellMouseEventArgs クラス
DataGridViewCellMouseEventArgs メンバ
System.Windows.Forms 名前空間
DataGridView クラス
DataGridView.Columns プロパティ
DataGridViewCell クラス


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

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

辞書ショートカット

すべての辞書の索引

「DataGridViewCellMouseEventArgs.ColumnIndex プロパティ」の関連用語

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

   

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



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

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

©2025 GRAS Group, Inc.RSS