We've run into an issue when we add an aditional column to a grid that was not in the previously saved XML file. When using the LoadFromXml method the previously defined columns appear formatted as they appeared when the layout was saved.The new column though appears with no formatting even though in the Initializelayout event we are defining how we want the new column to appear.Is there a way when a new column is added to a grid to format it to appear like the other columnssaved in the XML file? Or, is there a way to ignore the XML file and use a default layout (like in the InitializeLayout event) to format the grid (and then the user would have to re-savethe format)?Any suggestions would be helpful.
Thanks
Hi James,
The saved XML file will only contain the old columns not the one that was added. I am not sure what you mean by is there a way to ignore the XML file and use the default layout. As long as you do not load the XML file it will be ignored, can you please update the case with more information.
Magued
Hi Magued,
Thanks for the reply. Here is the scenario in a little more detail. We have an application that is used by a fairly large number of people. The main form of this Windows application is a search/reporting form. The Wingrid on this form right now has 15 columns. Depending upon the user's own personal preferences they may want to hide 1 or more columns, change the order the columns are displayed, and/or change the widths of 1 or more columns. Saving the user's layout preferences in an XML file works great until we add a new column to the grid. So right now the grid has 15 columns, but when we add an additional column bringing the total up to 16, that new column does not get formatted like the others in the grid when we apply the layout from the XML file.When I said if there was a way that I could ignore the XML file, I was trying to determine if there was some method that I could use to determine if the number of columns in the grid was different than the number of columns in the XML file. If there was a difference between the two I would not use the XML file to format the grid and instead use the formatting in the InitializeLayout event.Right now if the user does not have an XML file layout saved we use the layout defined in the InitializeLayout event. One idea we had was to set a DateTime flag in a database table that we would update when we changed the layout of the grid. We could then compare this datetime flag to the file date of the XML file. If the XML file is older than the DateTime flag then we would ignore (or even delete) the XML file and use the layout defined in the InitializeLayout event. But I was hoping we could do something by somehow checking the XML file instead.James
JamesPearson said:When I said if there was a way that I could ignore the XML file, I was trying to determine if there was some method that I could use to determine if the number of columns in the grid was different than the number of columns in the XML file. If there was a difference between the two I would not use the XML file to format the grid and instead use the formatting in the InitializeLayout event.
What you can do is load the layout into an UltraGridLayout variable, rather than loading it directly into the grid. Then you can examine the bands and columns in the layout and compare them to the actual grid bands and columns to detect changes.
If there are no changes, you can either load the layout into the grid from the file, or you can load it into the grid directly from the UltraGridLayout variable in your code using grid.DisplayLayout.CopyFrom.
Hello!i am having this exact problem now, but i cant find how to load the xml into a UltraGridLayout to do the comparison,
would anyone have an example i could use please, or point me in the correct location?
thanks