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.
I don't see anything wrong with this code. Perhaps you could post a small sample project demonstrating the exception so I can check it out?
sorry I haven't find an option to upload a zip file. I have created a new post with the zip file. Please treat these two posts as same. Please take my solution from this link,
http://community.infragistics.com/forums/p/51229/268209.aspx#268209
and have a look at this and suggests me where I am doing wrong.