My approach is similar to the accepted answer from TcK. The problem I ran into was that I had an event handler for a group of controls that responded to VisibleChanged using an event handler that controls the controls inside the Panel. The problem was (of course) that visibility changed when the form was first loaded, but after the .Load () event.
I created and set the bool value for the form:
private bool formShown = false;
and then added the following line to the form Form_Load ()
this.Paint += (s, args) => { formShown = true; };
with the first line of my VisibleChanged () event handler:
if(!formShown) { return; }
Short and functional.
source share