I have usecase where I have some 3 to 4 ultragrid and 2 to ultraCharts which are inserted into a UltraGridBagLayoutpanel and showed in a form. Now I am using UltraWinDockManager to persist this info to layout file as a xml file. However it persisting the window sizes and positioing correctly, it is not persisting the columninfos in a grid like column width, column ordering etc. I have found a method in UltraGrid to save to layout file. It will persist to the new layout file otherthan the whole layout file. Is there a way to persist this column info to the same layout file which also persists other panels info.
Can anyone tell me how should I get this?
Thanks,Sanjeev.
Hi Sanjeev,
You can persist both layouts into the same file if you want to. What you do is create a FileStream. Then you can save the DockManager into that stream and then the grid into the same stream.
When you load the layouts, you have to do it in the same order in which you saved them. The order is not important but it must be consistent.
Hi Mike,
I tried this approach.
In Mainform I have methods to save and load layout files:
For Saving:
In my mainform:
String layoutFile = "C://Mylayout.xml";
using (FileStream fs = new FileStream(layoutFile , FileMode.Create, FileAccess.Write)) { this.myUltraDockManager.SaveAsXML(fs); myUltraGridPanel.SaveToXml(fs); }
In my Grid:
public void SaveToXml(FileStream fs) { myUltraGrid.DisplayLayout.SaveAsXml(fs, PropertyCategories.All); }
For loading:
public void LoadFromXml()
{
String layoutFile = "C://Mylayout.xml"; try { using (FileStream fs = new FileStream(layoutFile, FileMode.Open, FileAccess.Read))
{ this.myUltraDockManager.LoadFromXML(fs); myUltraGridPanel.LoadFromXML(fs); } }
}
In My grid Panel, I have this code:
public void LoadFromXML(FileStream fs){ myUltraGrid.DisplayLayout.LoadFromXml(fs, PropertyCategories.All); }
But I have ended up with an exception while loading in Ultragrid panel's load method. The exception says the Root Element is missing.
Please tell me where I am doing wrong or point me to correct location where I can find some examples.
Thanks,
Sanjeev.