MenuBarSelected on hidden page panel

I have a container embedded in a page panel and its MenuBarSelected event fires. I anticipated that it wouldn’t fire and it’s causing a conflict.

What is the best way for me to detect that that container control is not showing from within the context of the control panel, which knows nothing about what it’s embedded within.

You could make use of the Visible property to know inside the container whether to ignore the MenuBarSelected event.

It seems redundant, but whatever changes the PagePanel SelectedPanelIndex would also tell the container it is no longer visible like this:

DesktopContainer1.Visible = (PagePanel1.SelectedPanelIndex = DesktopContainer1.PanelIndex)

But now, in the Container’s MenuBarSelected event handler you can check the Visible property and return early. (Return false to let the event bubble to the next handler.)

1 Like

yeah, or disable it, but I’m worried that flipping the visibility will lead to more flicker on Windows (which is pretty bad already).

You could use your own property instead of a framework one to avoid changing the visual state.

1 Like

that’s what I’m doing. I made a sub-class of DesktopContainer with “isShowing” as a property. I was just preferring to not have to do this.

Thanks, Tim. Have a good weekend.