代码之家  ›  专栏  ›  技术社区  ›  Mark

如何在Datagridview C中为特定列设置列标题文本#

  •  36
  • Mark  · 技术社区  · 17 年前

    如何在Datagridview C中为特定列设置列标题文本#

    7 回复  |  直到 15 年前
        1
  •  52
  •   ljs TheVillageIdiot    17 年前

    有

        public Form1()
        {
            InitializeComponent();
    
            grid.Columns[0].HeaderText = "First Column"; 
            //..............
        }
    

    here here .

        2
  •  51
  •   Marc Gravell    17 年前

    作为参考,如果你绑定到一个类,你可以在你的类型中通过 DisplayNameAttribute

    [DisplayName("Access key")]
    public string AccessKey { get {...} set {...} }
    

        3
  •  6
  •   DarthJDG chetan borse    15 年前
    grid.Columns[0].HeaderText
    

    grid.Columns["columnname"].HeaderText
    
        4
  •  2
  •   DarthJDG chetan borse    15 年前
    Dg_View.Columns.Add("userid","User Id");
    Dg_View.Columns[0].Width = 100;
    
    Dg_View.Columns.Add("username", "User name");
    Dg_View.Columns[0].Width = 100;
    
        5
  •  2
  •   Scott Keith    14 年前
    private void datagrid_ColumnHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
    {
        string test = this.datagrid.Columns[e.ColumnIndex].HeaderText;
    }
    

    HeaderText

        6
  •  0
  •   Mattia72    9 年前

    YourForm.Designer.cs 文件,例如:

    private System.Windows.Forms.DataGridViewCheckBoxColumn dataGridViewCheckBoxColumn1;    
    private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn2; 
    

    如果你给它们起了有用的名字,你可以设置 HeaderText

    usefulNameForDataGridViewTextBoxColumn.HeaderText = "Useful Header Text";
    
        7
  •  -1
  •   Mazen Ahmed    8 年前

    dgv。列[0]。HeaderText=“您的页眉”;

    推荐文章