Hi,
I am using BindingList (which has collection of object classes) as datasource to the grid.
And the column header in text is picking value from the Public properties in the class.
Is there a way i can change the column header txt .
Thanks!
Well, that should be pretty easy, actually, since the grid uses the same keys from the data source.
targetGrid.DisplayLayout.Bands[myUltraDataColumn.Band.Key].Columns[myUltraDataColumn.Key].Header.Caption = "My caption";
If I only know the UltraDataColumn, how can I get back to the related UltraGridColumn?
Hi Mark,
A DataColumn has no visible component, so it doesn't have a caption or any kind of display text. It just has a key. So you have to change the text on whatever control is displaying the data, not on the UltraDataSource itself.
The code you have here that works is working because you are setting the caption on the UltraGridColumn, not the UltraDataColumn.
Dear Vaibhav (and all) --
Please help with this follow-up question to the original-question and the (so far) best answer.
I am adding columns like this...
UltraDataColumn myUltraDataColumn = this.datasourceCostingDetail.Band.Columns.Add("MyColKey", typeof(string));
...so how do get a "handle" to that column and then set the header text for it?
I tried this...
myUltraDataColumn.Band.Columns["MyColKey"].Header.Caption = "My Nice Name";
...but the "Header" is not available there and it does not compile.
This does work...
targetGrid.DisplayLayout.Bands[0].Columns["MyColKey"].Header.Caption = "My Nice Name";
...but it seems klunky and has a magic number and so maybe there is a better way to do it.
So how can one set the UltraDataColumn header text if one is using the "Columns.Add" method to add new columns?
Please advise.
Thanks.
-- Mark Kamoski