DataGridTableStyle dgStyle = new DataGridTableStyle();
dgStyle.MappingName = "tab_conf";
dgStyle.ColumnHeadersVisible = true;
dgStyle.HeaderBackColor = Color.LightGreen;
dgStyle.BackColor = Color.LightPink; DataGridColumnStyle dgCol1 = new DataGridTextBoxColumn();
dgCol1.MappingName = "tab_style";
dgCol1.HeaderText = "表类型";
dgStyle.GridColumnStyles.Add(dgCol1); DataGridColumnStyle dgCol2 = new DataGridTextBoxColumn();
dgCol2.MappingName = "tab_style_no";
dgCol2.HeaderText = "序号";
dgStyle.GridColumnStyles.Add(dgCol2); DataGridColumnStyle dgCol3 = new DataGridTextBoxColumn();
dgCol3.MappingName = "field_name";
dgCol3.HeaderText = "字段名";
dgStyle.GridColumnStyles.Add(dgCol3); DataGridColumnStyle dgCol4 = new DataGridTextBoxColumn();
dgCol4.MappingName = "field_type";
dgCol4.HeaderText = "数据类型";
dgStyle.GridColumnStyles.Add(dgCol4);
dgPoundConf.TableStyles.Clear();
dgPoundConf.TableStyles.Add(dgStyle);
dgPoundConf.SetDataBinding(dst,"");
为何无法修改datagrid中字段的标题名称??
dgStyle.MappingName = "tab_conf";
dgStyle.ColumnHeadersVisible = true;
dgStyle.HeaderBackColor = Color.LightGreen;
dgStyle.BackColor = Color.LightPink; DataGridColumnStyle dgCol1 = new DataGridTextBoxColumn();
dgCol1.MappingName = "tab_style";
dgCol1.HeaderText = "表类型";
dgStyle.GridColumnStyles.Add(dgCol1); DataGridColumnStyle dgCol2 = new DataGridTextBoxColumn();
dgCol2.MappingName = "tab_style_no";
dgCol2.HeaderText = "序号";
dgStyle.GridColumnStyles.Add(dgCol2); DataGridColumnStyle dgCol3 = new DataGridTextBoxColumn();
dgCol3.MappingName = "field_name";
dgCol3.HeaderText = "字段名";
dgStyle.GridColumnStyles.Add(dgCol3); DataGridColumnStyle dgCol4 = new DataGridTextBoxColumn();
dgCol4.MappingName = "field_type";
dgCol4.HeaderText = "数据类型";
dgStyle.GridColumnStyles.Add(dgCol4);
dgPoundConf.TableStyles.Clear();
dgPoundConf.TableStyles.Add(dgStyle);
dgPoundConf.SetDataBinding(dst,"");
为何无法修改datagrid中字段的标题名称??
解决方案 »
- datagridview添加数据后再删除出错。。。高手请进
- myFilterGraph as IBasicAudio 编译错误
- 【版务帖】2009年10月C#版务帖
- zedGraph中GraphPane的YAxis.Title ,能够呈水平方向放置么?
- 怎么用C#做个类似QQ式的下拉菜单
- 求最新MSN API接口 获取好友邮箱列表
- .net中,有关在SOCKET编程中,汉字编码问题.
- 求下列算法的逆运算
- 能不能用C#做一个像window资源管理器这样的文件浏览器?
- 关于循环冗余CRC校验问题求教
- 为什么datagrid里不能显示表里的整型字段??在线等待……
- ThreadPool.QueueUserWorkItem 内存泄漏 为啥
dataGrid1.TableStyles.Add(....);
是否和你dst中对应的Tablename名称相同?
dataGrid1.TableStyles.Clear();
dataGrid1.TableStyles.Add(....);
这两句话有啊
dgPoundConf.TableStyles.Clear();
dgPoundConf.TableStyles.Add(dgStyle);
不知道为何??
to 小人物:
表名也是对的呀!!!
dataGrid1.TableStyles.Add(....);
up
DataSet dst;
SqlDataAdapter adp = new SqlDataAdapter("select * from table",con);
adp.Fill(dst);//这种是用的默认表名
adp.Fill(dst,"tab_conf");//这种是指定表名