I want to know if the user has changed the grid settings since it was originally loaded. That way I can ask the user if he would like to save the setting when exiting the application. How do I find out if the grid setting have changed since it was loaded?
Thanks!
Hi,
What settings do you mean? If you mean things like the column width, then the grid does not track that kind of information. You could handle all the events that fire when the user changes the things you are interesting in and keep a flag. You would use events like AfterColPosChanged, AfterRowFilterChange, AfterSortChanged, etc.
I am referring to any of the grid settings that get persisted. Like you pointed out, there are the colposchanged, filterchange, etc etc. If there were some discrete ones I were interested, I could trap them and set some flag to indicate change to the setting. But, I am just interested in finding out if ANY of the settings have changed.
It is the equivalent of the prompt "do you want to save changes?" one gets when closing a modified document. I want to do something similar when a user has modified some grid settings and is about to close the application. And for that I am looking for some property on the grid which would help me.
Mike Saltzman"] Out of curiosity, are there cases where the user will not want to save the settings?
Out of curiosity, are there cases where the user will not want to save the settings?
I think it is reasonable to ask a user to save if he cares to use the setting again.
In my case, I have this elaborate scheme implemented which saves the settings for for the various Infragistics controls incl dockmanager, etc that the application uses. I would like to implement such that the controlling persistance manager would interrogate each control it manages whether its persistable setting have changed and if so, it would prompt the user to save the setting at time of form closure. That way if user has forgotten to save he has an opportunity (kind of like when we try before saving a change in Word, VisualStudio, etc)
I will submit a request as you suggest.
Could you serialize and store the grid layout to a stream (after you have bound the data and initialized the grid etc.) using DisplayLayout.Save, then serialize again before closing and binary compare the two streams to see if anything has changed? This covers the 'anything persistable' criteria!
You also get some control over what gets compared this way through the PropertyCategories arg.
Jonesmar, your idea is very good one. It would definitely address the "catch-everything" problem. So there is binary compare function? I was not aware of that. if you have some keywords or sample code, can you copy/paste to me?
I was thinking of using MemoryStream then just use ToArray() to get the byte[ data
There's no library function to compare the arrays so check the lengths are equal and just use a for loop to compare the contents.
Hm, that sounds like an excellent idea. :)