473,405 Members | 2,310 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

saving forms as XML

Hi all, I would like to know if there is a way to save a form (and I mean
its definition, not the contents of its controls) to a XML file that can
then be loaded and showed at run time. In more general terms, I would like
to know if there is a way (a language or something like that) that makes it
possible to create/modify forms that will then be showed to the user.
Hope to have been clear enaugh...
Thank you for your help,
Alessandro
Mar 19 '07 #1
2 1431
"halex2000" <po*******@libero.itwrote in message
news:RO********************@twister2.libero.it...
Hi all, I would like to know if there is a way to save a form (and I mean
its definition, not the contents of its controls) to a XML file that can
then be loaded and showed at run time. In more general terms, I would like
to know if there is a way (a language or something like that) that makes
it possible to create/modify forms that will then be showed to the user.
Hope to have been clear enaugh...
There isn't something "automatic", but you could do it with a relatively
small amount of code. To save the form definition as XML, you could iterate
over the Controls collection of the form and save the characteristics of
each control either directly as XML, or in a class defined by you and then
serialize that class. You will need a recursive routine for this purpose,
since the controls could be nested inside other controls.
In order to recover the XML file and show the form to the user, you
would have to read the xml, and then iterate through it, create the controls
that it defines, set their properties, and add them to the appropriate
Controls collection.
If you want it completely generic, so that it supports every possible
kind of Control without having to handle all of them in a large switch
construct, you could use Reflection to save and recreate the controls and
their properties. All in all, it seems like this would be a pretty neat
utility class to have around. Maybe someone has already written and
published something like this?

Mar 19 '07 #2

"Alberto Poblacion" <ea******************************@poblacion.orgh a
scritto nel messaggio news:uK**************@TK2MSFTNGP05.phx.gbl...
"halex2000" <po*******@libero.itwrote in message
news:RO********************@twister2.libero.it...
>Hi all, I would like to know if there is a way to save a form (and I mean
its definition, not the contents of its controls) to a XML file that can
then be loaded and showed at run time. In more general terms, I would
like to know if there is a way (a language or something like that) that
makes it possible to create/modify forms that will then be showed to the
user.
Hope to have been clear enaugh...

There isn't something "automatic", but you could do it with a
relatively small amount of code. To save the form definition as XML, you
could iterate over the Controls collection of the form and save the
characteristics of each control either directly as XML, or in a class
defined by you and then serialize that class. You will need a recursive
routine for this purpose, since the controls could be nested inside other
controls.
In order to recover the XML file and show the form to the user, you
would have to read the xml, and then iterate through it, create the
controls that it defines, set their properties, and add them to the
appropriate Controls collection.
If you want it completely generic, so that it supports every possible
kind of Control without having to handle all of them in a large switch
construct, you could use Reflection to save and recreate the controls and
their properties. All in all, it seems like this would be a pretty neat
utility class to have around. Maybe someone has already written and
published something like this?
Thank you, I was thinking something similar as well. The pourpose of this
all is to have some kind of scripting system to interact with the app and
with a database, and for the forms we were thinking to this. Do you think
there are better ways? For Example, are there scripting language available
for use withing C# apps that provide GUI and DB connection capabilities?
Mar 19 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: William Morris | last post by:
We have a number of clients using a web application. Each client sees a slightly different version of, say, a contact input page. As a simple example, Client #1 sees demographics, plus religious...
3
by: cdj | last post by:
Hi all, I've got a picturebox on a form, and a save button. When I go to save, the app craps out with the following error: ================== An unhandled exception of type...
4
by: melanieab | last post by:
Hi, I'm trying to save a bitmap file so I can print it later. I have Image.Save("sImage.bmp",System.Drawing.Imaging.ImageFormat.Bmp); The file sImage.bmp shows up in the bin\debug folder but...
12
by: Anon | last post by:
Hello All! I was wondering how I can go about saving the last string entered into a textbox. I would like to save username or pwd info in textboxes in my forms so that users don't have to...
2
by: steve | last post by:
Hi All I have a program which takes photos of members using a web cam, then saves them as bitmap files The bitmap is used by a Picturebox to display the photo and clicking on a button enables...
18
by: TORQUE | last post by:
Hi, Im wondering if anyone can help me with a problem. I have a form with more than 50 unbound fields. Some of the fields will be blank from time to time. This seems to be where im having...
6
by: Jeff | last post by:
Hey (and thank you for reading my post) In visual web developer 2005 express edition I've created a simple website project.. At this website I want users who register to be able to upload a...
0
by: Magnus Bergh | last post by:
I am developing an application for pocketpc and this involvs a but of juggling with different forms. I have an "order entry" type of application. On the main form I have a grid which displays...
9
by: Wingot | last post by:
Hey, I am using Visual Studio 2008 Beta 2 for some application development in C#, but I presume that the following question applies equally well to any environment.
1
by: romcab | last post by:
Hi guys, I would like to ask your help about saving in ado.net. I was able to update it only on the display but when I check the database, it is not updated. I paste below my code and hopefully...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.