DataGridView动态添加列

DataGridView动态添加列必须指定列的类型

 

DataGridViewTextBoxColumn Column1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
Column1.HeaderText =“Column1”;
Column1.Name = "Column1";

dataGridView1.Columns.Insert(iColIndex, Column1);

private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
{
            iColIndex = e.ColumnIndex;
 }

你可能感兴趣的:(DataGridView动态添加列)