Saving the state of UI

  • Thread starter Mahesh Devjibhai Dhola [MVP]
  • Start date
M

Mahesh Devjibhai Dhola [MVP]

Hi,

User can adjust the size of columns of a table or the position of splitter
in UI. We want these adjustments to be remembered when we restart the
application. Currently, we are saving these adjustments by the user in an
XML and saving that XML. We read the XML upon restart and make calls to set
the adjustments. This approach becomes difficult as we add more controls and
more settings can be made by the user. What other techniques can be use to
save (perhaps automatically) the STATE OF UI? As in Java, can we use
Serialization of UI to save its state [Java's Swings control are
serializable while in .Net, Form and all the controls are not serializable]?
Any pointers to articles on various approaches to SAVING THE STATE OF THE
ADJUSTMENTS made by the user will be greatly appreciated.

Thanks in Advance,

Regards,
Mahesh
 
C

Cor Ligthert

Mahesh,

The first question is for me, how many of your controls are dynamicly placed
on the form. In a form where I use two splitters are that beside from the
form the top, the left side, the hight and the width the only things extra
the splitter side of the sized panels. The rest is performed by the docking.

(I save this kind of information in registry)

I hope this helps,

Cor
 
J

Jeffrey Tan[MSFT]

Hi Mahesh,

Thanks for your post!!

Yes, currently, there is no build-in way to serilize the UI controls in
Windows Forms. We have to implement the serializer ourselves. We can
leverage binary serialization or xml serialization based on your request,
for more information, please refer to:
"HOW TO: Serialize Web Server Controls by Using Visual C# .NET"
http://support.microsoft.com/?id=328547

Also, there is another way to serialize the UI controls' state at runtime,
that is implementing the Winform design-time code generating model, to
achieve this, we also have to implement a lot of Winform design-time
interfaces, there is a sample implementation in the KB below:
"INFO: Code Sample That Demonstrates How to Create a Custom Form Designer
by Using Visual C# .NET"
http://support.microsoft.com/default.aspx?scid=kb;en-us;813808

Note, in the sample, the serialization code is in the
SampleDesignerLoader.cs, you may refer the Save method. As we can see, it
leverages C# code DOM to serialize the controls as C# code file, or use
XmlDocument classes to serialize controls as xml file.

The advantage for this option is that it gives the customer the consistent
way with Winform design-time code generation.

Hope this helps

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
J

Jeffrey Tan[MSFT]

Hi Mahesh,

Does my reply make sense to you? If you still have any concern on this
issue, please feel free to feedback. thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
M

Mahesh Devjibhai Dhola [MVP]

I am sorry Jeffrey but still i have not get any reply so i can not say about
your response.
 
J

Jeffrey Tan[MSFT]

Hi Mahesh,

Oh, it seems that you failed to get my reply in the newsgroup, which is
very strange. Anyway, I will paste my original response message in this
reply, for your information:

"Yes, currently, there is no build-in way to serilize the UI controls in
Windows Forms. We have to implement the serializer ourselves. We can
leverage binary serialization or xml serialization based on your request,
for more information, please refer to:
"HOW TO: Serialize Web Server Controls by Using Visual C# .NET"
http://support.microsoft.com/?id=328547

Also, there is another way to serialize the UI controls' state at runtime,
that is implementing the Winform design-time code generating model, to
achieve this, we also have to implement a lot of Winform design-time
interfaces, there is a sample implementation in the KB below:
"INFO: Code Sample That Demonstrates How to Create a Custom Form Designer
by Using Visual C# .NET"
http://support.microsoft.com/default.aspx?scid=kb;en-us;813808

Note, in the sample, the serialization code is in the
SampleDesignerLoader.cs, you may refer the Save method. As we can see, it
leverages C# code DOM to serialize the controls as C# code file, or use
XmlDocument classes to serialize controls as xml file.

The advantage for this option is that it gives the customer the consistent
way with Winform design-time code generation."
==============================================================
Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top