By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,759 Members | 1,727 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,759 IT Pros & Developers. It's quick & easy.

Howto structure a GUI?

P: n/a
MM
Hi, First off, I'm just beginning .NET and GUI stuff and am very
inexperienced. I have worked through a number of GUI tuts in books but
all the GUI code to handle events for all the controls in these examples
is always in the single file of the main form. What is the correct way
to 'sub-divide' various GUI sections into differnet files? For instance,
with all my anticipated controls, this one file would be hundreds if not
thousands of lines long. My 'data' naturally sub-divides into a number
of 'sections' but I don't know how to seperate them into a number of files.

For example, I want to have a Data/GUI class that contains a grid (using
a Listview that is initially empty), a button to create a new row, a
button alongside each row to change order, etc and these are all
associated with an ArrayList of data (initially empty also). So, in my
reckoning I want to create a class that contains the data class and all
the GUI elements.

Questions:
If you create this class, how do you add the gui stuff to the main form,
how do you set position of the control in the main form, etc (and more
questions x infinity-1).

Any hints, URLs with some meaty examples, jokes (to relieve stress), etc
would be greatly appreciated. Thanks for any and all help. matthew.
Nov 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Hi ,

This is my take on the issue and i hope it helps upto some extent .

You may check up some specific design pattern that may be explicitly for
GUI design but the main idea always remains :

1. Create a base form or set of forms , with common set of controls or
properties , which has a wide usage and needn't be repeated manually on
every form . You may even go for separate user controls for very
commonly used control pattern .

2. Create custom controls when u need functionality different from
standard control and they can referenced as a dll to your main form and
all the relevant properties are available as such viz : position X , Y ,
as these control will be part of Main form's Control Collection .

3. Don't Mix GUI and Data Layer at any point , again create the data
Layer as a separate dll , where you can have a class for each type data
Storage in memory structure and play around . You can refrence them to
your GUI Forms / assemblies .

Just for E.g :

An Architecture that i remembered using in our of our project :

a. GUI Layer - TopMost Layer , which set of base forms , that every new
form is bound to derive from . It has refernce to UIP layer dll .

b. UI Process Layer , for inter communication between various GUI,
there's no one form directly referencing other form . it has refernce to
Service Interface Layer dll .

c. Service Interface Layer , for communication with external agents ,
3rd party tools . It has refernce to BC layer .

d. BC Layer , Business communication and incorportaing necessary logic
.. It has refernce to DAL layer dll .

e. DAL ( data Access layer ) is used for communication with db .

This is just an example to show that how , one layer is only dependant
on layer below it and there's flow of logic and information through a
pipe as direct referncing of two far apart layers is not done viz : UI
can't access SI directly , it bound to go through UIP .

I hope it makes some sense , as whole idea is to create as much
flexibility at each level as possible , so that changes are very easy to
incorporate , for e.g: Near the project completion , when there are
around 200 forms in total , there comes a request to change the header
or some other control , then doing it in each form is killing , you can
just change in base form and it's done for all .

Your sepcific doubt related to ListView and Button is very much
acheivable with generic controls available , in case u need specific
code , revert back with exact requirements , i will create a working
example and send accross .

regards ,

Mrinal
MM wrote:
Hi, First off, I'm just beginning .NET and GUI stuff and am very
inexperienced. I have worked through a number of GUI tuts in books but
all the GUI code to handle events for all the controls in these examples
is always in the single file of the main form. What is the correct way
to 'sub-divide' various GUI sections into differnet files? For instance,
with all my anticipated controls, this one file would be hundreds if not
thousands of lines long. My 'data' naturally sub-divides into a number
of 'sections' but I don't know how to seperate them into a number of files.

For example, I want to have a Data/GUI class that contains a grid (using
a Listview that is initially empty), a button to create a new row, a
button alongside each row to change order, etc and these are all
associated with an ArrayList of data (initially empty also). So, in my
reckoning I want to create a class that contains the data class and all
the GUI elements.

Questions:
If you create this class, how do you add the gui stuff to the main form,
how do you set position of the control in the main form, etc (and more
questions x infinity-1).

Any hints, URLs with some meaty examples, jokes (to relieve stress), etc
would be greatly appreciated. Thanks for any and all help. matthew.

Nov 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.