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

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

DataGridViewColumn.DataPropertyName プロパティ

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

DataGridViewColumn がバインドされている、データ ソース プロパティの名前またはデータベースの列の名前を取得または設定します

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

Public Property DataPropertyName As
 String
Dim instance As DataGridViewColumn
Dim value As String

value = instance.DataPropertyName

instance.DataPropertyName = value
public string DataPropertyName { get;
 set; }
public:
property String^ DataPropertyName {
    String^ get ();
    void set (String^ value);
}
/** @property */
public String get_DataPropertyName ()

/** @property */
public void set_DataPropertyName (String value)
public function get DataPropertyName
 () : String

public function set DataPropertyName
 (value : String)

プロパティ
DataGridViewColumn関連付けられている、プロパティの名前またはデータベースの列の名前。

解説解説
使用例使用例

各列が表すプロパティ選択する方法次のコード例示します

    Private Sub SetupGrid()
        knights = New List(Of Knight)
        knights.Add(New Knight(Title.King, "Uther",
 True))
        knights.Add(New Knight(Title.King, "Arthur",
 True))
        knights.Add(New Knight(Title.Sir, "Mordred",
 False))
        knights.Add(New Knight(Title.Sir, "Gawain",
 True))
        knights.Add(New Knight(Title.Sir, "Galahad",
 True))

        ' Initialize the DataGridView.
        dataGridView1.AutoGenerateColumns = False
        dataGridView1.AutoSize = True
        dataGridView1.DataSource = knights

        dataGridView1.Columns.Add(CreateComboBoxWithEnums())

        ' Initialize and add a text box column.
        Dim column As DataGridViewColumn =
 _
            New DataGridViewTextBoxColumn()
        column.DataPropertyName = "Name"
        column.Name = "Knight"
        dataGridView1.Columns.Add(column)

        ' Initialize and add a check box column.
        column = New DataGridViewCheckBoxColumn()
        column.DataPropertyName = "GoodGuy"
        column.Name = "Good"
        dataGridView1.Columns.Add(column)

        ' Initialize the form.
        Controls.Add(dataGridView1)
        Me.AutoSize = True
        Me.Text = "DataGridView object binding
 demo"
    End Sub

    Private Function CreateComboBoxWithEnums()
 As DataGridViewComboBoxColumn
        Dim combo As New
 DataGridViewComboBoxColumn()
        combo.DataSource = [Enum].GetValues(GetType(Title))
        combo.DataPropertyName = "Title"
        combo.Name = "Title"
        Return combo
    End Function

#Region "business object"
    Private Class Knight
        Private hisName As String
        Private good As Boolean
        Private hisTitle As Title

        Public Sub New(ByVal
 title As Title, ByVal name As
 String, _
            ByVal good As Boolean)

            hisTitle = title
            hisName = name
            Me.good = good
        End Sub

        Public Property Name() As
 String
            Get
                Return hisName
            End Get

            Set(ByVal Value As
 String)
                hisName = Value
            End Set
        End Property

        Public Property GoodGuy() As
 Boolean
            Get
                Return good
            End Get
            Set(ByVal Value As
 Boolean)
                good = Value
            End Set
        End Property

        Public Property Title() As
 Title
            Get
                Return hisTitle
            End Get
            Set(ByVal Value As
 Title)
                hisTitle = Value
            End Set
        End Property
    End Class
#End Region
private void EnumsAndComboBox_Load(object sender,
 System.EventArgs e)
{
    // Populate the data source.
    bindingSource1.Add(new Knight(Title.King, "Uther",
 true));
    bindingSource1.Add(new Knight(Title.King, "Arthur",
 true));
    bindingSource1.Add(new Knight(Title.Sir, "Mordred",
 false));
    bindingSource1.Add(new Knight(Title.Sir, "Gawain",
 true));
    bindingSource1.Add(new Knight(Title.Sir, "Galahad",
 true));

    // Initialize the DataGridView.
    dataGridView1.AutoGenerateColumns = false;
    dataGridView1.AutoSize = true;
    dataGridView1.DataSource = bindingSource1;

    dataGridView1.Columns.Add(CreateComboBoxWithEnums());

    // Initialize and add a text box column.
    DataGridViewColumn column = new DataGridViewTextBoxColumn();
    column.DataPropertyName = "Name";
    column.Name = "Knight";
    dataGridView1.Columns.Add(column);

    // Initialize and add a check box column.
    column = new DataGridViewCheckBoxColumn();
    column.DataPropertyName = "GoodGuy";
    column.Name = "Good";
    dataGridView1.Columns.Add(column);

    // Initialize the form.
    this.Controls.Add(dataGridView1);
    this.AutoSize = true;
    this.Text = "DataGridView object binding demo";
}

DataGridViewComboBoxColumn CreateComboBoxWithEnums()
{
    DataGridViewComboBoxColumn combo = new DataGridViewComboBoxColumn();
    combo.DataSource = Enum.GetValues(typeof(Title));
    combo.DataPropertyName = "Title";
    combo.Name = "Title";
    return combo;
}
#region "business object"
private class Knight
{
    private string hisName;
    private bool good;
    private Title hisTitle;

    public Knight(Title title, string name,
 bool good)
    {
        hisTitle = title;
        hisName = name;
        this.good = good;
    }

    public Knight()
    {
        hisTitle = Title.Sir;
        hisName = "<enter name>";
        good = true;
    }

    public string Name
    {
        get
        {
            return hisName;
        }

        set
        {
            hisName = value;
        }
    }

    public bool GoodGuy
    {
        get
        {
            return good;
        }
        set
        {
            good = value;
        }
    }

    public Title Title
    {
        get
        {
            return hisTitle;
        }
        set
        {
            hisTitle = value;
        }
    }
}
#endregion
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
DataGridViewColumn クラス
DataGridViewColumn メンバ
System.Windows.Forms 名前空間
DataGridView クラス
DataGridView.ColumnDataPropertyNameChanged イベント


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

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

辞書ショートカット

すべての辞書の索引

「DataGridViewColumn.DataPropertyName プロパティ」の関連用語

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

   

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



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

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

©2025 GRAS Group, Inc.RSS