I have a question on designing Win forms application on VS 2010.
My mini application consists of a single form where the controls are placed in multiple panel and group box controls. Initially the panels and group boxes will be kept hidden. Based on need, the visibility of the container controls will be set to true. Since I have more container controls, for the sake of convenience I have kept the size of my form big and placed the container controls in various places so that i can quickly double click on the controls in the container to go to its handler.
But I have written a method which sets the controls in place and it is getting called in the constructor. Below is the relevant code snippet.
namespace CrossMath { public partial class frmCrossMath : Form { public frmCrossMath() { InitializeComponent(); setControlsInPosition(); } private void setControlsInPosition() { this.grpL1.SetBounds(571, 73, 165, 307); grpL1.Visible = false; this.grpL2.SetBounds(371, 73, 165, 307); //this.grpL2.SetBounds(571, 73, 165, 307); grpL2.Visible = false; pnlOptions.SetBounds(28, 62, 706, 324); pnlOptions.Visible = false; this.ClientSize = new System.Drawing.Size(780, 461); } }
setControlsInPosition is my method which sets the controls in position. I found InitializeComponants is the internal method which does the same thing (apart from instantiating the controls). I see a performance implication (form flickering) because of this.
Is there a better way to handle this scenario ? Can we force .net to optimize this code during compilation as both the methods are called by the constructor ?
Thanks in Advance,
S.Sudharsan