Reputation: 1223
I have the following problem. With DevExpress I want to set an XtraGrid to bind to a List.
Therefore I took a BindingList
private BindingList<string> aBindingList = new BindingList<string>();
The list behind was filled with a Linq Query (a user entry is computed, then different results are shown as grid for further processing). As I was not able to directly put the result of aa query in a bindinglist, therefore
if (null != aStringList) aBindingList = new BindingList<string>(aStringList);
And now the problem appeared. I want to use the BindingList as Datasource of an XtraGrid, and use a correct header name.
gridControlXtraGrid.DataSource = aBindingList ;
This one display the rows, but uses an ugly header "Column".
DevExpress.XtraGrid.Views.Base.ColumnView aColumnView = gridControlXtraGrid.MainView as DevExpress.XtraGrid.Views.Base.ColumnView;
aColumnView.Columns[0].FieldName = "My Header";
sets a header, but then no longer rows are displayed.
gridControlXtraGrid.DataSource = aBindingList ;
DevExpress.XtraGrid.Views.Base.ColumnView aColumnView = gridControlXtraGrid.MainView as DevExpress.XtraGrid.Views.Base.ColumnView;
aColumnView.Columns[0].FieldName = "My Header";
gridViewExcludableProperties.PopulateColumns();
Finally shows the data rows again, but no longer the header.
So I either can set the column header, or see the rows.
So how can I set both at once?
Upvotes: 2
Views: 5928
Reputation: 1223
Okay, if anybody else is searching for this:
aColumnView.Columns[0].Caption
must be used, not aColumnView.Columns[0].FieldName
gridView.Rows[0].HeaderCell.Value = "Some Value"; seemed to be much clearer with normal Grids in the wording...
Upvotes: 3