Hi,
For example i have 4 columns say A, B, C and D in Ultrawingrid. When the grid gets opened at run time
i want to change the order of the columns say B, D A and C and want to save this order, so that when
i close the grid and open it next time i have to get the columns in B, D, A and C order.... Also i
need a option or a button where in i can reset the order of the columns to A,B,C and D.
Could you please advise on this.
Thank you,
Basavaraj P Hiremath.
Hi Basavaraj,
You can use the Save and Load methods on the grid's DisplayLayout.
Hi Mike,
Thank you for replying. Could u please give me an example how this can be done.. it will be very helpful to me.
Thank you.
There's really nothing to it:
// Save the layout
this.ultraGrid1.DisplayLayout.SaveAsXml("filename.xml");
// Load the layout
this.ultraGrid1.DisplayLayout.LoadFromXml("filename.xml");
Thanks Mike....
But here i am not using XML file for the grid layout. Here these are Bound columns in the grid with the header property set in the designer. So when the grid layout is changed at run time only the columns whose position is changed is returned. i.e. AfterColPosChanged ( sender, e) is fired, and the value returned into e....
I just had look into outlook.. where in i can swap the columns for eg say from and Received... and close it the next time i open the outlook i get the updated grid.. this functionality i want to implement in my project..
Waiting for your reply..
Thanks once again.
I'm not sure what you mean by this. The save and load methods I mentioned above save/load the layout of the grid to an XML file. This has nothing to do with whatever you are using, it's functionality built-in to the grid. You could also save and load the layout using Binary. But again, this has nothing to do with anything you are using or the grid's DataSource. It doesn't save the data, it's the grid's Layout that is saved.
This also has nothing to do with AfterColPosChanged. Typically, you would save the layout in the Form_Closed event and load it in the Form_Load after setting the grid's DataSource.
Did you try the save and load methods?