将列的的headtext 赋值为你要现实的字符床就行了
eg:
BoundColumn bc;
bc = new BoundColumn();
bc.Headtext = "你要现实的字符创"
eg:
BoundColumn bc;
bc = new BoundColumn();
bc.Headtext = "你要现实的字符创"
解决方案 »
- 缺少组件,应该很简单的问题
- vs2008窗体里怎么添加图片的菜单栏
- 前台和后台代码的协调问题??帮顶有分!
- C#中数据集内部的查询
- 在学winform中的自定义控件,没办法引入System.Drawing,请教各位?
- winform datagrid 共4列,如何让第2列和第3列之间的距离增加,将4列数据鲜明的分成2部分?
- 从c#传带注释的sql语句去db2执行。。。 怎么做才对?!
- 如何截取指定字符串
- C#如何调用wsc写的com组件。。。谢谢!!!高人请进
- jQuery ajax队列怎样实现?第二个队列获取第一个队列的返回值
- dy_2000_abc(芝麻开门)兄请来这儿领分!!!!!!谢谢!!!!!!
- C#的初学者---《C#入门经典》--怎样最好的利用?
下面,提供了一段示例程序,供您参考:
private void button1_Click(object sender, System.EventArgs e)
{
DataSet myDs = getDataSet();
DataGridTableStyle DGStyle;
DataGridColumnStyle GridColumn1,GridColumn2,GridColumn3;
DGStyle = new DataGridTableStyle();
DGStyle.MappingName = "Categories";
DGStyle.HeaderBackColor = Color.Beige;
DGStyle.HeaderForeColor = Color.Red; // get the PropertyDescriptorCollection for the data
// source and data member.
PropertyDescriptorCollection pcol;
pcol = this.BindingContext[myDs,"Categories"].GetItemProperties();
// create column style for column1
GridColumn1 = new DataGridTextBoxColumn(pcol["CategoryId"]);
GridColumn1.MappingName = "CategoryId";
GridColumn1.HeaderText = "目录ID";
GridColumn1.Alignment = HorizontalAlignment.Center;
GridColumn1.Width = 50;
DGStyle.GridColumnStyles.Add(GridColumn1); GridColumn2 = new DataGridTextBoxColumn(pcol["CategoryName"]);
GridColumn2.MappingName = "CategoryName";
GridColumn2.HeaderText = "目录名称";
GridColumn2.Width = 100;
DGStyle.GridColumnStyles.Add(GridColumn2); GridColumn3 = new DataGridTextBoxColumn(pcol["Description"]);
GridColumn3.MappingName = "Description";
GridColumn3.HeaderText = "简介";
GridColumn3.Width = 300;
DGStyle.GridColumnStyles.Add(GridColumn3); dataGrid1.TableStyles.Add(DGStyle);
dataGrid1.DataSource = myDs.Tables["Categories"].DefaultView;
} private DataSet getDataSet()
{
string connString = "Server=SHA-RICKIE-01;Database=northwind;uid=user;pwd=user";
SqlConnection myConn = new SqlConnection(connString);
DataSet myDs = new DataSet();
string sqlString = " Select CategoryId,CategoryName,Description From Categories";
SqlDataAdapter myAdapter = new SqlDataAdapter(sqlString,myConn);
myAdapter.Fill(myDs,"Categories"); return myDs;
}— 微软全球技术中心 VB支持中心本贴子以“现状”提供且没有任何担保,同时也没有授予任何权利。具体事项可参见使用条款(http://support.microsoft.com/directory/worldwide/zh-cn/community/terms_chs.asp)。
为了为您创建更好的讨论环境,请参加我们的用户满意度调查(http://support.microsoft.com/directory/worldwide/zh-cn/community/survey.asp?key=(S,49854782))。
ds.Tables[0].Columns["ZZLXMC"].ColumnName = "执照类型";
将所要显示的列:select xxx ..... as 要要要... from ...
即可!