Need a certain code

Post here about scripting and programming for HaloPC (audio, network, ai, etc.)
Post Reply
User avatar
Eaton




Enthraller

Posts: 1639
Joined: Thu Jun 14, 2007 4:16 pm
Location: USA

Need a certain code

Post by Eaton »

Hi. I have been trying to make it so that a button is disabled when there are no open MDI windows. I know the code goes something like this, but I cannot figure out the right way to put it in.

if (Mdi.Children.Count = 0)

button2.Enabled = false;
Image
User avatar
LuxuriousMeat





Posts: 824
Joined: Thu Nov 03, 2005 6:43 pm
Location: zzzzzzzzzzzzzzzz
Contact:

Re: Need a certain code

Post by LuxuriousMeat »

Eaton wrote:Hi. I have been trying to make it so that a button is disabled when there are no open MDI windows. I know the code goes something like this, but I cannot figure out the right way to put it in.

if (Mdi.Children.Count = 0)

button2.Enabled = false;

Code: Select all

if (this.MdiChildren.Length < 1) button1.Enabled = false;
But if you want this to happen when the last child form closes you could use this code in the child forms 'FormClosed' event:

Code: Select all

this.Dispose();
MainFormType parent = (MainFormType)this.MdiParent;
if (parent.MdiChildren.Length < 1)
    parent.MethodToDisableButton();
else
    parent.MethodToEnableButton();
Or, to disable the button you could change the button's protection level to public and just disable it.
Image
Post Reply