Hi,
I have Ultra Grid in windows application. I want to change column display order at runtime.
I'm wondering if there is a way to change the display order of column. Please help me ASAP
Yes, use the InitializeLayout event and set the column.Header.VisiblePosition on each column. Note that you must set the columns in order so as to prevent the positoin of one column from interfering with another.
So this is correct:
e.Layout.Bands[0].Columns["My First Column"].Header.VisiblePosition = 0;
e.Layout.Bands[0].Columns["My Second Column"].Header.VisiblePosition = 1;
e.Layout.Bands[0].Columns["My Third Column"].Header.VisiblePosition = 2;
This would be wrong:
e.Layout.Bands[0].Columns["My First Column"].Header.VisiblePosition = 2;
e.Layout.Bands[0].Columns["My Second Column"].Header.VisiblePosition = 0;
Thank you for the fantastic and brilliant answer.
I am linking a WinCombo to a control and depending upon whether the entry is numeric or alphabetical, I can then change the dataview.sort field.
Thus I can show the combo with the first column being the sorted one.
Hi Mike:
I have been trying to control the VisiblePosition of the columns in an Ultragrid (winforms) using an attribute on the DataSource's underlying type. The VisiblePosition doesn't seem to take - the columns result in an apparantly random order:
If it is still true in 2009.2 that we must set the column VisiblePosition in the order of the properties of the datasource type, due to how WinGrid uses reflection internally, then it seems to me that I need to go with the .Columns.FromKey[name].Move(#) strategy, and that my strategy will not work. Do you concur?
This property is not available for the UltraWebGrid?