C # - DevExpress XtraGrid - Master / Detail - Display Format

Scenario

  • I have a DevExpress XtraGrid.
  • The displayed data is in the main / detailed format, as a result of which pressing the “+” button at the beginning of the line expands the details for this main line.
  • I implemented this by attaching a grid data source to a dictionary of objects that contain their own dictionary property (for storing details).

Problem

  • What I want to do is format the data in specific columns of the part.
  • However, I cannot get the column, presumably because it is a subitem of the main row (and therefore not checked?)
  • Below are 2 sample code for implementations that I have tried so far that do not work.

Trying to solve the code

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 with thanks.

+3
1

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 = ....
}
+5

Source: https://habr.com/ru/post/1762426/


All Articles