C# - 的DevExpress XtraGrid中 - 主/详细信息 - 显示格式 [英] C# - DevExpress XtraGrid - Master/Detail - Display Format

查看:1200
本文介绍了C# - 的DevExpress XtraGrid中 - 主/详细信息 - 显示格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


  • 我有一个的DevExpress XtraGrid中。

  • 显示的数据是在主/细节的格式,因此点击+在行开始扩展该主行的详细信息。

  • 我的网格数据源绑定到对象的字典来实现这一点,包含自己的字典属性(按住细节)。


  • 我想要做的是格式在细节的特定列中的数据。

  • 但是,我不能让该列的保持,大概是因为它是一个主行的子元素(因此没有得到遏制?)

  • 下面是到目前为止,不工作我已经试过了实现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";
            }
            }



帮助非常感谢。

Help greatly appreciated.

推荐答案

要在详细的GridView格式的值,你应该先获取该对象的实例。相当多这样的标准方式是处理主GridView的MasterRowExpanded事件处理程序。在此事件处理程序,你还可以设置列的DisplayFormat:

To format values in a detail GridView, you should obtain an instance of this object first. Pretty much the standard way of doing this is to handle the Master GridView's MasterRowExpanded event handler. In this event handler you can also set a column's 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 = ....
}

这篇关于C# - 的DevExpress XtraGrid中 - 主/详细信息 - 显示格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆