views:

51

answers:

2

In my current app I have a Tree control on a page of a TabControl which is inside a panel of a SplitContainer control. The tree control can thus be hidden by either hiding the SplitContainer panel, or switching to another TabPage in the TabControl.

In the Form's menus there are commands which act on the currently selected Node in the tree. I do not want these options to be enabled when the user can not see what is selected.

Is there a simple way of determining when the TreeView goes out of view with out subscribing to the events of both the TabControl and the SplitContainer separately?

A: 

Test the TreeView's Visible property. There is also a VisibleChanged event.

bbudge
A: 

You can create a boolean member variable. In the tabchanged event, test to see if the treeview tab is selected and set the variable appropriately. Also, subscribe to the event that is fired when the splitter view size is changed. Test the width or height of the splitter to see if your treeview is hidden. If it is, set the variable here to. Then all you need to do is test your new member variable.

icemanind