PDA

Click to See Complete Forum and Search --> : mdi form problem


Asgill
Mar 8th, 2004, 01:22 AM
private void btnReg_Click(object sender, System.EventArgs e)
{
bool FrmIsOpen = false;

if(this.MdiParent != null && this.MdiParent.MdiChildren != null)
{
for (int i=0; i < this.MdiParent.MdiChildren.Length; i++)
{
if (this.MdiParent.MdiChildren[i].GetType() == typeof(FrmPassword))
{
FrmIsOpen = true;
break;
}
}
}
if (!FrmIsOpen)
{
FrmPassword r = new FrmPassword();
r.MdiParent = this;
r.Show();
}

/*FrmPassword r = new FrmPassword();
r.MdiParent= this;
r.Show();*/
}




i have this code here that checks whether a frm is already opened or not, if its not opened, it opens one, and if its already opened it'll show the one thats already opened and not a new one...all seems to be fine....but i still get the same form opening twice...whats wrong?

Pirate
Mar 8th, 2004, 06:45 PM
private void btnReg_Click(object sender, System.EventArgs e)
{
bool FrmIsOpen = false;
if(this.MdiParent != null && this.MdiParent.MdiChildren != null)
{
for (int i=0; i < this.MdiParent.MdiChildren.Length; i++)
{
if (this.MdiParent.MdiChildren[i].GetType() == typeof(FrmPassword))
{
FrmIsOpen = true;
break;
}
}
}
if (!FrmIsOpen)
{
FrmPassword r = new FrmPassword();
r.MdiParent = this;
r.Show();
} else {

/*FrmPassword r = new FrmPassword();
r.MdiParent= this;
r.Show();*/
}
}