【发布时间】:2010-08-31 09:09:35
【问题描述】:
场景
- 我有一个 DevExpress XtraGrid。
- 显示的数据采用主/明细格式,单击行首的“+”可展开该主行的明细。
- 我通过将网格数据源绑定到包含自己的 Dictionary 属性(以保存详细信息)的对象字典来实现这一点。
问题
- 我要做的是格式化详细信息特定列中的数据。
- 但是,我无法获取该列,可能是因为它是主行的子元素(因此没有得到检查?)
- 以下是迄今为止我尝试过但不起作用的 2 个代码示例。
尝试的代码解决方案
gridView1.Columns["Price"].DisplayFormat.FormatType = DevExpress.Utils.FormatType.Numeric;
gridView1.Columns["Price"].DisplayFormat.FormatString = "n4";
private void gridView1_RowCellStyle(object sender, RowCellStyleEventArgs e)
{
GridView View = sender as GridView;
if (e.Column.FieldName == "Price")
{
e.Column.DisplayFormat.FormatType = DevExpress.Utils.FormatType.Numeric;
e.Column.DisplayFormat.FormatString = "n4";
}
}
非常感谢您的帮助。
【问题讨论】:
标签: c# devexpress