dynamic winforms UI

P

Peted

Can anyone suggest a best practice approach to building a dynamic
winforms UI.

Just as an example somehting like a billing application where you
enter a customer billing data and the billing options, the UI and the
winform controls you have visible are dynamic and can change as
information is entered, so that there is a dependency between between
the data you enter and how other controls react, and/or are even
selectable

In addtion the UI should be dynamic in that it can vary when it is
first shown. So the problems i imagine with this is the winforms is
built by a designer, and that makes its layout fixed.
So should i look at multiple forms, and show the relevant one only or
is a better approach to build the UI in code and not use the designer
at all.

Does anyone have any info on a best practice approach for this sort of
task or any advice or any tutorials etc.


thanks for any info

Peted
 
A

Alberto Poblacion

Can anyone suggest a best practice approach to building a dynamic
winforms UI.

Just as an example somehting like a billing application where you
enter a customer billing data and the billing options, the UI and the
winform controls you have visible are dynamic and can change as
information is entered, so that there is a dependency between between
the data you enter and how other controls react, and/or are even
selectable

In addtion the UI should be dynamic in that it can vary when it is
first shown. So the problems i imagine with this is the winforms is
built by a designer, and that makes its layout fixed.

If you look at the designer-generated code, you will find out that the
designer is actually writing code which generates the layout dynamically
when it is executed from the form constructor.
There is nothing to prevent you from writing code like that and
executing it yourself, thereby generating a dynamic layout. For instance, to
add a new textbox to the form you do this:
TextBox t = new TextBox();
t.Top = 200; //Change properties as needed
this.Controls.Add(t);

Basically, whatever you add to the Controls collection of the Form will
appear on screen. Of course, you can also remove elements from the
collection.
 
I

Ignacio Machin ( .NET/ C# MVP )

Can anyone suggest a best practice approach to building a dynamic
winforms UI.

Just as an example somehting like a billing application where you
enter a customer billing data and the billing options, the UI and the
winform controls you have visible are dynamic and can change as
information is entered, so that there is a dependency between between
the data you enter and how other controls react, and/or are even
selectable

In addtion the UI should be dynamic in that it can vary when it is
first shown. So the problems i imagine with this is the winforms is
built by a designer, and that makes its layout fixed.
So should i look at multiple forms, and show the relevant one only or
is a better approach to build the UI in code and not use the designer
at all.

Does anyone have any info on a best practice approach for this sort of
task or any advice or any tutorials etc.

thanks for any info

Peted

You can do the UI as dynamic as you want. You can read the description
from a XML file and create the controls at runtime.
you would need a good framework though to handle the events of such a
form.
We use something similar where all the interface is defined in a XML
file.
Take a look at the Model View Presenter pattern as a way to handle the
user interaction
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top