tags:

views:

486

answers:

2

Hi Guys,

I've created a Mdi window with a panel. On this panel i've placed some buttons which open different child forms. The problem i'm having is that I only want a user to be able to open one child form/window at a time. I have been disabling the buttons on the buttons click event to open the child window and enabling them again on the child form close event. But this is rather tedious as there are many buttons. Is there a easier way to do this???

Thanks

A: 

The first thing I'd do, would be to put the enable/disable functionality into a single method. The method would take a bool argument for enable/disable.

void HandleButtons(bool enable)
{
    toolBarbutton1.Enabled = enable;
    toolBarbutton2.Enabled = enable;
    toolBarbutton3.Enabled = enable;
    toolBarbutton4.Enabled = enable;
}
Brad Bruce
A: 

When I'm doing something similar, I will throw all of the buttons into a panel and just disable the entire panel.

Dabas