I want to save the reordered positions of the groups in an explorer bar in a db table and reorder it back when the application is restarted. Is there any way to do this? The save settings property of the explorer bar doesnt save the ordering of the groups. It just shows how many are shown and minimized. The groups are created at runtime based on a user permission
You can use the SaveAsXml/SaveAsBinary methods to persist the state of the control; these methods maintain a group's ordinal position within the collection.
I tried that and it seem to save the ordinal position. Is there any way I could save this in the db table instead of my hard drive?
Also my group click events doesnt work any more after I do a LoadFromXml. Why would this be happening?
You can use SaveAsXml to save to a MemoryStream, use the MemoryStream's ToArray method to stream the data to a byte array, and then save the byte array to a database field of type varchar (for example).
Registering as a listener of an event is done on the application level, so LoadFromXml cannot automatically do that for you. If you are instantiating the control dynamically, then loading the serialized data, you would then have to register as a listener of the event.
Thanks that worked.
Is there any way to persists the width of the explorer bar? I want to be able to resize the explorer bar and have it stay that way everytime I bring up the application.
The Width property is inherited from the System.Windows.Forms.Control class; psersisting its value is typically handled by the designer. If you are doing this stuff dynamically, one solution would be to stash all the data that the control does not persist itself into a custom object, and assign that object to the Tag property. The Tag property gets persisted, assuming the contents are serializable (make sure to add the Serializable attribute to the class), so it will get persisted out to the stream along with the other data. Note that with this approach, after calling the LoadFromXml method, you would have to cast the Tag property to this custom class, and set the Width property yourself.
Thanks. I will try that. what you said makes a lot of sense.