Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. XMLSerialize and Microsoft Controls

XMLSerialize and Microsoft Controls

Scheduled Pinned Locked Moved C#
question
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • 3 Offline
    3 Offline
    3Dizard
    wrote on last edited by
    #1

    Sorry for posting this again. What I want to do is save the state of my windows form. What I heard so far XMLSerializing is a good way to go. If I got it right: Due to containing interfaces many classes can't be serialized. So the Form itself can't be serialized. So I need to serialize elements of this form. These are Controls (Labels and UserControls). If the above applies, I see no way doing so, except serializing lets say the Text of a Label and then later deserialize the string, create a new Label and set the Text to the deserialized string, which is a really bad situation. Is there any better way? Thanks for helping me out.

    B 1 Reply Last reply
    0
    • 3 3Dizard

      Sorry for posting this again. What I want to do is save the state of my windows form. What I heard so far XMLSerializing is a good way to go. If I got it right: Due to containing interfaces many classes can't be serialized. So the Form itself can't be serialized. So I need to serialize elements of this form. These are Controls (Labels and UserControls). If the above applies, I see no way doing so, except serializing lets say the Text of a Label and then later deserialize the string, create a new Label and set the Text to the deserialized string, which is a really bad situation. Is there any better way? Thanks for helping me out.

      B Offline
      B Offline
      BoneSoft
      wrote on last edited by
      #2

      You don't need to recreate the controls dynamically. Just catalog the information you need to save, organize it into some XML format, then use XSD.exe or something like Skeleton Crew[^] to generate an XML serializable model. Then on form load, read the XML file and use the resulting model to update the controls affected by your information, and on form closing fill a model with your information and serialize it out to the XML file. You can restrict your data to the text in text fields, or the form's size, or whatever you want to persist. Keep it simple.


      Try code model generation tools at BoneSoft.com.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups