I have a tab control in a windows form. It's working great, except for the following example. When I have tabpage2
selected, all controls on tabpage1
return their visible
property as FALSE which actually is untrue because they are all set to visible = false
.
I suppose it's because the tabpage1
is set to visible = false
so all child controls inherit FALSE.
Of course if tabpage1
is selected, then all controls return the correct value for the visible property.
There must be a work around. Does anyone have a solution?
To hide a tab: tabControl. TabPages. Remove(tabPage);
Windows TabControl is a useful control that allows you display multiple dialogs tabs on a single form by switching between the tabs. A tab acts as another Form that can host other controls. Figure 1 shows an example of TabControl in Visual Studio . NET, which allows you to switch among multiple files using the tabs.
To select a tab page on the form, first click its tab, then click its body. In the top combo box of the Properties window, select the name of the desired property page. On the form, click the tab control. In the Properties window, click the TabPages field and click its ellipsis button.
You can simply use: tabPage. Enabled = false; This property is not shown, but it works without any problems.
The Visible property is a bit special, its getter doesn't return the value you assigned. It tells you if the control is actually visible. Which it is not if it is placed on a tab page that isn't selected. This is by design.
Getting the actual "intends to be visible" state isn't supported. You'd get it out of GetState(2) but that's an internal method. If you're really desperate then you could use Reflection. But the proper way is to just keep track of it yourself.
Since the Visible
property of your panel is not behaving in the way you expect, try setting the Panel's Tag
property to something or other instead, and use that to determine whether or not to fail the validation.
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