Alec Sanger
Alec Sanger

Reputation: 4562

Preventing a predesigned tab in a TabControl from loading

Forgive the probably silly question - I'm not used to working with GUIs.

I've got a TabControl that's been prebuilt in the designer. There are many tabs, but only certain ones need to show up based on a variable at the time of loading the form. I originally tried using the Remove command on the FormLoad to remove the unneeded tabs, but because there are multiple tabs with multiple additional objects in each tab, they visibly load and then disappear and it's rather ugly.

Thank you.

Upvotes: 2

Views: 94

Answers (2)

Roman Starkov
Roman Starkov

Reputation: 61540

Call Remove in the form constructor, right after InitializeComponents. That happens way before the form is shown.

Upvotes: 1

fejesjoco
fejesjoco

Reputation: 11903

Design your tabs contents as usercontrols. On the main form, each tab only contains a single control. If you want load-on-demand, then make tabs empty in the designer, and put the corresponding usercontrol in the tab when it's first shown.

Upvotes: 1

Related Questions