Hello,
I am using an ultragrid in my application. I am also allowing the end users to change column width, cell font name, font size, horizontal alignment, vertical alignment, column caption etc.
Right now, I am saving all these settings in the format of string for each column (like key-value pairs) but as the number of columns are getting increased, it is becoming quite difficult to implement more and manage.
I am looking at better ways and found that SQL Server has XML datatype and Grid has methods like SaveToXML() and LoadFromXML(). If I use this way, If I use SaveToXML() will it save all the settings (apperance settings) which I discussed above or only a part of it.
Let me know whether this works in my case or not and also I appreciate if there are any better ways.
Thanks
Nagarjun.
Yes, that is exactly what the SaveAsXml/LoadFromXml methods were designed for.
Is there any example relating to it in KB?
I have one quick question.
I am showing users an option form which contains various options to change for the grid columns like how we see in an excel sheet.
like showing them horizontal align, vertical align,font name,font size, fixed, decimal places etc.
As now, I am reading these settings for the grid by saving as xml and loading from xml datatype,
What is the easiest way to read the settings for a particular column so that I can display their current settings on the option form.
I know reading the appearance object of the column will work but I just want to confirm whether there are any better ways to do it.
Hope I make the question clear.
Nagarjun
Hi Nagarjun,
nag4054 said: Is there any example relating to it in KB?
I'm sure there are samples included with NetAdvantage that save and load the grid's layout. I'm not sure if there is a KB article, though. Saving and loading the layout is really very simple, you just create a MemoryStream in this case and use the grid.DisplayLayout.Save/Load methods on it.
Saving that stream to a database field can be a bit tricky. And there is a KB article on how to do that:
HOWTO:How can I save a stream to a database?
nag4054 said:What is the easiest way to read the settings for a particular column so that I can display their current settings on the option form.
Assuming that your code is applying the colors, fonts, etc. using the column.CellAppearance, then yes, the easiest way to get this information is to load the layout and examine the properties on the appropriate column.
Also note that you can create a variable of type UltraGridLayout and use the load method of that variable to load the stream data, thus loading the layout into memory without affecting the on-screen grid. This makes it possible for you to examine the properties which are stored in the stream in case you want to show the users some kind of preview of what's in a particular layout. When you want to copy the loaded layout variable into the grid, you use the grid.DisplayLayout.CopyFrom method.
I have an options form like this
Now when the user clicks on a column and click options I am opening the options form with the selected column properties loaded in.
Can you suggest me a best way to do it?
Can you give me an example how to read a particular column settings from the UltraGridLayout variable.
You do this the same way you read properties from the grid.
grid.DisplayLayout.Bands[x].Columns[columnKey]
layout..Bands[x].Columns[columnKey]
You mean you want a single header to span multiple columns?
There are a couple of ways you can do this, but which one you use depends on exactly what you want.
The best thing to do would be to use Groups, either in the normal layout or a GroupLayout.
Is there any way to do colspan in header? If so, can you give me an example.
nag4054 said:What is the best way to compare one appearance object of one column to another appearance object?
The Equals method will just compare instances, so that will not work. There's no easy way to compare two appearances. You will have to check every property and compare each one individually.
nag4054 said:How to fix two columns so that if you try to move one column, both the columns needs to move accordingly. Is this possible?
There is no functionality to link to columns in the grid. What you could do is handle the AfterColPosChanged event and fix up the column's positions after the user moves a column. But you will probably need to use an anti-recursion flag to prevent the event from firing continuously.
How to fix two columns so that if you try to move one column, both the columns needs to move accordingly. Is this possible?
What is the best way to compare one appearance object of one column to another appearance object?
Infragistics.Win.AppearanceBase FirstColumnApp = PrintGrid.Selected.Columns[0].Appearance; for (int i = 1; i <= PrintGrid.Selected.Columns.Count - 1; i++) { if (PrintGrid.Selected.Columns[i].Appearance.Equals(FirstColumnApp))
Appearance1.Equals(Appearance20 not working.
What is the best way for it?