Create user interface on the fly???

  • Thread starter Thread starter BVM
  • Start date Start date
B

BVM

Hi, all:

I want to populate controls on a form based on what user select. I define the layout of the form and controls in a xml file, like this:

<Label id="lblName" text="Company Name" Width="100" height="24" layout="Dock-Top" Event="Click" EventHandler="ClickLabel"/>

Then my program should understand it and put it in the correct place and create event: lblName.Click += new EventHandler(this.ClickLabel);

(Sounds like ASP.NET and Scripting)

Do you have any idea on how to do it?

Many Thanks!

Dennis Huang
 
Dennis,
Three ways I can think of:

1. Do as ASP.NET does and generate source & assemblies using the
System.CodeDom namespace. The generated source & assemblies could either be
stored on disk or dynamically recreated each time. You could even include
code snippets in the XML, that gets injected into the generated assembly.

2. Parse the XML and use reflection System.Reflection & System.Activator to
dynamically create controls and set properties of said controls.

3. Use System.Reflection.Emit to directly create assemblies.

I would inclined to use option 1.

Hope this helps
Jay

Hi, all:

I want to populate controls on a form based on what user select. I define
the layout of the form and controls in a xml file, like this:

<Label id="lblName" text="Company Name" Width="100" height="24"
layout="Dock-Top" Event="Click" EventHandler="ClickLabel"/>

Then my program should understand it and put it in the correct place and
create event: lblName.Click += new EventHandler(this.ClickLabel);

(Sounds like ASP.NET and Scripting)

Do you have any idea on how to do it?

Many Thanks!

Dennis Huang
 
Thanks, Jay.

Very interesting.

If I write a piece of code and put it in xml file, can I retrieve it and
compile it and execute it?

And where I can find examples?

Thanks,

Dennis
 
Tobin,
As I find articles I make a note of them.

I have a MSDN subscriptions so a lot of times I search locally to find the
article then manually expand the tree to find it on the web, other times I
simply search MSDN on the web directly.

Jay
 
Jay B. Harlow said:
Tobin,
As I find articles I make a note of them.

I have a MSDN subscriptions so a lot of times I search locally to find the
article then manually expand the tree to find it on the web, other times I
simply search MSDN on the web directly.

Jay

Thanks for the response Jay. I think I may start making notes myself - alays
seem to come across a lot of good stuff, but then forget about it or where
it was!

Tobes
 
Back
Top