Tab controls (tab control) that do not appear are displayed Visible = false

I have a window-shaped tab control. It works great, except for the following example. When I selected tabpage2 , all the controls on tabpage1 return their visible property as FALSE, which is actually not true because they are all set to visible = false .

I suppose because the tabpage1 parameter tabpage1 set to visible = false , so all child controls inherit FALSE.

Of course, if tabpage1 selected, then all controls return the correct value for the visible property.

There must be work. Anyone have a solution?

+4
source share
3 answers

Since the Visible property of your panel does not behave as you expect, try setting the Panel Tag property to something or another instead and use this to determine whether to refuse the check.

+1
source

The Visible property is a bit special; its recipient does not return the value you assigned. It tells you whether the control is actually displayed. Which is not if it is placed on a tab that is not selected. This is by design.

Getting the actual state "intends to be visible" is not supported. You will get it from GetState (2), but this is an internal method. If you are really desperate, you can use Reflection. But the right way is to simply follow it on your own.

+11
source

Creating a small project to confirm this, if you check the Visible property of any control on the selected tab, it will return false because the control is not displayed.

If you are trying to determine which tab the user is viewing, you might be better off checking the SelectedTab or SelectedIndex TabControl property.

0
source

Source: https://habr.com/ru/post/1335429/


All Articles