日期:2014-05-18 浏览次数:20795 次
private void mainform_Load(object sender, EventArgs e) { bindgrid(1) //显示datagridview1列 bindgrid(2) //显示datagridview2列 } private void bindgrid(int i) { dataGridView1.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells); DataGridViewTextBoxColumn col_prog = new DataGridViewTextBoxColumn(); col_prog.DataPropertyName = "program"; col_prog.HeaderText = "栏目"; col_prog.Name = "program"; col_prog.ReadOnly = true; col_prog.AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells; dataGridView1.Columns.Add(col_prog); }