I have just discovered that UserControls in a TabControl will not load until the parent TabPage is selected. Is there a way to prevent this delay loading? I need to initialize the UserControls when the main form loads.
The TabControl
does not treat its controls specially, in fact it is normal under all circumstances for the Load
event on a UserControl
to occur immediately before the control is displayed for the first time. The TabPage
is responsible for showing the control, therefore it will only be 'loaded' when first selected.
To overcome this (perfectly normal) Windows Forms behaviour, you could move your initialisation code to a separate method and call it when the Form
loads, or you could just place your initialisation code in the UserControl
's constructor instead. Either way, you can perform your initialisation immediately.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With