Scenario
- I have a DevExpress XtraGrid.
- The data displayed is in a master/detail format, whereby clicking the '+' at the start of the row expands the detail for that master row.
- I have implemented this by binding the grids datasource to a dictionary of objects that contain their own Dictionary property (to hold the detail).
Problem
- What I want to do is format the data in specific columns of the detail.
- However, I cannot get hold of the column, presumably because it is a sub-element of the master row (and therefore does not get checked?)
- Below are 2 code examples of the implementations I have tried so far that do not work.
Attempted Code Solutions
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.