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

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

DataGridViewBand.Tag プロパティ

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

バンド関連付けられているデータを含むオブジェクト取得または設定します

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

解説解説
使用例使用例

Tag プロパティ使用して色を格納し、これを取得して BackColor プロパティ設定するコード例次に示します

Private Sub PostRowCreation()
    SetBandColor(dataGridView.Columns(0), Color.CadetBlue)
    SetBandColor(dataGridView.Rows(1), Color.Coral)
    SetBandColor(dataGridView.Columns(2), Color.DodgerBlue)
End Sub

Private Shared Sub SetBandColor(ByVal
 band As DataGridViewBand, _
    ByVal color As Color)
    band.Tag = color
End Sub

' Color the bands by the value stored in their tag.
Private Sub Button9_Click(ByVal
 sender As Object, _
    ByVal e As System.EventArgs) Handles
 Button9.Click

    For Each band As DataGridViewBand
 In dataGridView.Columns
        If Not band.Tag Is
 Nothing Then
            band.DefaultCellStyle.BackColor = _
                CType(band.Tag, Color)
        End If
    Next

    For Each band As DataGridViewBand
 In dataGridView.Rows
        If Not band.Tag Is
 Nothing Then
            band.DefaultCellStyle.BackColor = _
                CType(band.Tag, Color)
        End If
    Next
End Sub
private void PostRowCreation()
{
    SetBandColor(dataGridView.Columns[0], Color.CadetBlue);
    SetBandColor(dataGridView.Rows[1], Color.Coral);
    SetBandColor(dataGridView.Columns[2], Color.DodgerBlue);
}

private static void SetBandColor(DataGridViewBand
 band, Color color)
{
    band.Tag = color;
}

// Color the bands by the value stored in their tag.
private void Button9_Click(object sender, System.EventArgs
 e)
{

    foreach (DataGridViewBand band in dataGridView.Columns)
    {
        if (band.Tag != null)
        {
            band.DefaultCellStyle.BackColor = (Color)band.Tag;
        }
    }

    foreach (DataGridViewBand band in dataGridView.Rows)
    {
        if (band.Tag != null)
        {
            band.DefaultCellStyle.BackColor = (Color)band.Tag;
        }
    }
}
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
DataGridViewBand クラス
DataGridViewBand メンバ
System.Windows.Forms 名前空間
DataGridView クラス
DataGridViewRow
DataGridViewColumn
Guid



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

辞書ショートカット

すべての辞書の索引

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

   

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



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

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

©2025 GRAS Group, Inc.RSS