Multiple InitializeComponent for a winform

572 Views Asked by At

We have a highly compact winform with over 180 controls placed in it .
Most of these controls are dynamically placed , some are displayed /hidden based on some preferences.
As a part of optimizing the code i have decided to split the InitializeComponent into three , and in the constructor of the form based on a parameter i will choose the right InitializeComponent which will have only controls wrt to that workflow initalized.

Is this approach right , is there any other way of doing this

1

There are 1 best solutions below

2
On

Seems right to me, assuming you've given up the designer and write the InitializeComponent() methods yourself. Otherwise the designer might overwrite your code in some way.