0

I want to create a dynamic windows form in C# based on XML. i want to use the xmlTextReader class, and use the while (reader.read()) function that will go over the content of the XML and will create the form. it should be very simple (super simple!!) for example, if my XML contains:

 <TITLE>
  <Field>
    <field_name>Tom</field_name>
    <field_type>textbox</field_type>
    <is_mandatory>1</is_mandatory>
  </Field>
</TITLE>

it means i need a textbox with the name of "Tom" and it should be mandatory. and if i will create more "Field" elements, it will create another one below the textbox.

can you give me an example code of how to do it?

thanks!!!

2
  • And what is a question? Commented Apr 21, 2013 at 13:27
  • how to do it easily? :) Commented Apr 21, 2013 at 13:33

2 Answers 2

1

Sounds like you want some sort of dynamic form generation. Rather than reinvent the wheel, you could use something like FormFactory to build your forms from the XML schema. (see the last example for programmatically creating forms)

Sign up to request clarification or add additional context in comments.

Comments

0

To answer your question, I'd need to write up a spec. And only you know what features you want.

  • Pick a technology (asp.net, winforms, silverlight, WPF, what-ev)
  • Pick a library for parsing XML.
  • Iterate across your XML document.
  • Spit out new Label() and new TextBox() as appropriate on some big switch statement
  • Decide how to template and style all of this.
  • Do some databinding.

I recommend using Joel Spolskys template for doing specifications because it is the best balance between process and pragmatics. Most spec templates tend to be non-pragmatic and pure-process.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.