How to handle many controls in a form?

I am wondering how to handle a form with lots of controls. Are you filling out all the processing code on the form? This is how I did it, but my last project gets out of hand due to all the controls I need to work with. I have a menu, several toolbars, tabcontrols filled with controls, a status bar, ... you get the idea. I am thinking about using partial classes to separate things, but this is probably a bad idea. I just need advice on what I should do.

+4
source share
4 answers

I would recommend using UserControls to break down your functionality. By moving independent parts into instances of UserControl, you can separate your logic.

In addition, the use of an architectural template such as MVC or MVP can greatly help in increasing the application.

+8
source

If you are building something in accordance with the basic forms, as you describe, you really need to develop an architecture with a certain level of business and data. Your actual functionality and manipulations should be divided into a class library created specifically for processing abstracted information / operations. The same thing with calls and data processing. They should be abstracted into a separate library, which is responsible for managing the input / output operations with your data sources.

This means that the code in your actual form comes down to the elements that are really necessary to control the display and direct behavior (clicks, rollovers, menus, etc.). Even some of them can be combined if you effectively manage form states. The bottom line is that you want to get away from the form as much as possible and leave the form responsible for the immediate display.

+2
source

You must separate the controls into logical groups by functionality, and then move each group to its own UserControl.

+1
source

The best idea for simple applications is to move independent controls in UserControls or use the MVVP template, although it takes a little time to learn and implement to learn, but it simplifies your efforts to implement new features.

0
source

All Articles