Custom column names for DataGridView with associated DataSource

前端 未结 3 683
走了就别回头了
走了就别回头了 2020-12-05 13:28

How can I setup custom column names for DataGridView with associated DataSource?

Here is some code:

class Key
{
    public string Value { get; }
             


        
3条回答
  •  南笙
    南笙 (楼主)
    2020-12-05 14:05

    You should be able to change the header cells after you've set the datasource:

        if (dataGridView1.Columns["Value"] != null)
            dataGridView1.Columns["Value"].HeaderText = "Key";
        if (dataGridView1.Columns["Expiration"] != null)
            dataGridView1.Columns["Expiration"].HeaderText = "Expire";
    

提交回复
热议问题