按数据字段设置分层网格的头文本 - Telerik C#WinForms

时间:2017-04-06 06:10:50

标签: c# winforms telerik radgridview

我正在使用这样的模板创建分层网格:

GridViewTemplate template = new GridViewTemplate();
template.DataSource = query;
GridViewTextBoxColumn txtcolumn = new GridViewTextBoxColumn();
txtcolumn.FieldName = "Mobile";
txtcolumn.Name = "colMobile";
txtcolumn.HeaderText = "Mobile Number";
template.Columns.Add(txtcolumn);

正如您所见,标题文字只是一个简单的string,如何将其绑定到field的{​​{1}}?可能的?

1 个答案:

答案 0 :(得分:0)

列的

FieldName 属性实际上用于将列绑定到数据源字段。

例如,假设您的数据源包含两个字段, ID UserName

如果您想在 RadGridView 中添加一个反映 UserName 字段及其值的列,您只需要设置 FieldName = "您的专栏的用户名"

HeaderText 属性用于设置将在您的应用程序中显示的列的列标题文本。

例如,如果您要添加一个显示 UserName 字段值的列,但列名称将显示为用户名,则必须设置 FieldName =" UserName" HeaderText ="用户名"