如何改变标题文字中的DataGridView - 在代码的C#? [英] how to change header text in DatagridView - in code C#?
本文介绍了如何改变标题文字中的DataGridView - 在代码的C#?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何更改标题文本的datagridview以及如何添加或删除列? - 在C#代码
how to change header text in DatagridView and how to add or remove column - in C# code ?
感谢的提前
推荐答案
如果您正在使用数据绑定到一个类型,自动生成的列,这是 [显示名称(...)]
,即
If you are using data-binding to a type and auto-generated columns, this is the [DisplayName(...)]
, i.e.
[DisplayName("Last name")]
public string LastName {get;set;}
否则这就是的HeaderText
在列,即
grid.Columns[0].HeaderText = "Something special";
添加一列的基本方法是:
A basic way to add a column is:
int columnIndex = grid.Columns.Add("columnName", "Header Text");
或者你可以更具体,例如添加超链接的列:
Or you can be more specific, for example to add a column of hyperlinks:
grid.Columns.Add(new DataGridViewLinkColumn());
(你可以明显地设置新列第一多个属性)
(you could obviously set more properties on the new column first)
这篇关于如何改变标题文字中的DataGridView - 在代码的C#?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文