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";
}
}
非常感谢。
答案 0 :(得分:5)
要格式化GridView中的值,您应首先获取此对象的实例。几乎这样做的标准方法是处理Master GridView的MasterRowExpanded事件处理程序。在此事件处理程序中,您还可以设置列的DisplayFormat:
private void gridView1_MasterRowExpanded_1(object sender, CustomMasterRowEventArgs e) {
GridView master = sender as GridView;
GridView detail = master.GetDetailView(e.RowHandle, e.RelationIndex) as GridView;
detail.Columns["SomeColumn"].DisplayFormat = ....
}