日期:2014-05-17 浏览次数:21227 次
void AddOneViewColumn(string header)
{
DataGridViewTextBoxColumn dgvc = new DataGridViewTextBoxColumn();
dgvc.HeaderText = header;
dgvc.ReadOnly = true;
this.dataGridView1.Columns.Add(dgvc);
}
this.dataGridView1.DataSource = rs.DtRecord;
void DataBind(string cName,string property)
{
if (this.dataGridView1.DataSource == null)
MessageBox.Show("未绑定数据源");
this.dataGridView1.Columns[cName].DataPropertyName = property;
}
private void Form1_Load(object sender, EventArgs e)
{
this.dataGridView1.DataSource = rs.DtRecord;
DataBind("AAA", "A");
DataBind("BBB", "B");
DataBind("CCC", "C");
DataBind("DDD", "D");
DataBind("EEE", "E");
}
void InitDT()
{
DataColumn dc=new DataColumn("ID");
dc.AutoIncrement = true;
dc.AutoIncrementSeed = 1;
dc.AutoIncrementStep = 1;
dtRecord.Columns.Add(dc);
&nb