On Jun 20, 2:34 pm, "John" <J...@nospam.infovis.co.ukwrote:
Hi
Is it possible to enumerate all controls on a form and then save the info in
an xml file via code? Is it possible to reverse the process i.e. read info
from and xml and recreate all controls on a blank form? I am just trying to
find a way to cerate "templates" so users can choose which controls they
want to see and with what attributes; position, size, colour etc.
A code example would be great.
I don't have time to enter a bunch of sample code, but I think I can
point you in the right direction. The Form Class has a property that
is a collection of all controls on the form, so yes, you could
enumerate all controls on a form. Depending on how complex you expect
your forms to be, you need to remember that a form can be the parent
of a collection of controls. To write the out to XML, you need to
figure out the XMLSerializer Class, it ain't too hard, I figured it
out in just a couple of days. It is my impression that all classes are
serializable by default in VB but I could be wrong, you may have to
create a copy of the control object in order to serialize it (write it
to XML file using XMLSerializer class).
Everything you need to know plus sample code is all in the help files.