我从数据库中向datagridtable中倒入数据后,想改datagridtable的表头字段,
于是乎这样写的:this.dataGridView1[0, 0].Value = "c";
this.dataGridView1[1, 0].Value = "b";
可是不对呀,那位高手知道该怎么改?!谢谢了!!
于是乎这样写的:this.dataGridView1[0, 0].Value = "c";
this.dataGridView1[1, 0].Value = "b";
可是不对呀,那位高手知道该怎么改?!谢谢了!!
this.dataGridView1[1, -1].Value = "b";
{
// Add a GridTableStyle and set the MappingName
// to the name of the DataTable.
DataGridTableStyle TSAuthors = new DataGridTableStyle();
TSAuthors.MappingName = "Authors"; // Add a GridColumnStyle and set the MappingName
// to the name of a DataColumn in the DataTable.
// Set the HeaderText and Width properties.
DataGridColumnStyle TCFirstName = new DataGridTextBoxColumn();
TCFirstName.MappingName = " AV_FName";
TCFirstName.HeaderText = "First Name";
TCFirstName.Width = 75;
TSAuthors.GridColumnStyles.Add(TCFirstName); // Add the DataGridTableStyle instance to
// the GridTableStylesCollection.
dataGrid1.TableStyles.Add(TSAuthors);
}
这个方法我一步步跟,都走了,就是没反应,郁闷!!
select [字段1] as '表头1',[字段2] as '表头2' from [table] where [条件]
col.DataPropertyName = "Question_id";//数据库字段
col.HeaderText = "问题";
col.Name = "My";
this.dataGridView1.Columns.Add(col);
11楼那么简单说明问题了....
select a b from table:
中间没有 as
dataGrid1.TableStyles.Add(TSAuthors); TCFirstName.HeaderText属性就可以修改显示的字段标题