编程语言
首页 > 编程语言> > C# Winform表格DataGridView自定义列(文本列、ComboBox列)

C# Winform表格DataGridView自定义列(文本列、ComboBox列)

作者:互联网

例子:

DataGridView dv = this.dataGridView1;

//自定义普通文本列
DataGridViewTextBoxColumn dc3 = new DataGridViewTextBoxColumn();
            dc3.Name = "FMapName";
            dc3.DataPropertyName = "FMapName";
            dc3.HeaderText = "对应名称";
            dc3.ReadOnly = true;
            dv.Columns.Add(dc3);

//自定义ComboBox列(整个列的每一行都有一个ComboBox控件)
DataGridViewComboBoxColumn dc2 = new DataGridViewComboBoxColumn();
            dc2.HeaderText = "对应代码";
            dv.Columns.Add(dc2);  //注意要加上这句才能添加

 

标签:自定义,C#,ComboBox,Add,dv,dc2,dc3
来源: https://www.cnblogs.com/PER10/p/11541591.html