Tech Off Thread

2 posts

Forum Read Only

This forum has been made read only by the site admins. No new threads or comments can be added.

is there a way to serialize the state of a control?

Back to Forum: Tech Off
  • User profile image

    I have a custom forms control, with about 10 numeric boxes, a couple of radio button lists.  i would like to serialize/deserialize the state of that control as a part of another object.  The main object is being saved / opened on a regular basis, but I didn't expect the user wanting to save the on-screen state of this particular control.

    Is there a magic quick way of doing this, or do i have to come up with a way to save each field individually?

    (edit) using VB.NET 2003, migrating to VB 2005 soon...

  • User profile image

    Well you could write a generic serializer for a control that used reflection to save all the get/set properties into xml etc. and read the data back in.
    This is of course assuming that the control class is not serializable now (I have honestly not looked). Most classes can be marked as serializable and it will use all the public properties to get/set state.

Conversation locked

This conversation has been locked by the site admins. No new comments can be made.