How we can stop to creating new Instance on same click of form
-
hi friends,please help me. i have written code for into mdi form for openning a child form. private void menuItem7_Click(object sender, System.EventArgs e) { frmBaseForm frmLoad= new frmBaseForm(); frmLoad.MdiParent =this; frmLoad.Left =0; frmLoad.Top =0; frmLoad.Show(); } when i click menu more then once,this code open more then one form. i don't want that. it can be solve by using variable and may be enabling disabling the menu item. but i want optimum solution thnx a lot
-
hi friends,please help me. i have written code for into mdi form for openning a child form. private void menuItem7_Click(object sender, System.EventArgs e) { frmBaseForm frmLoad= new frmBaseForm(); frmLoad.MdiParent =this; frmLoad.Left =0; frmLoad.Top =0; frmLoad.Show(); } when i click menu more then once,this code open more then one form. i don't want that. it can be solve by using variable and may be enabling disabling the menu item. but i want optimum solution thnx a lot
Use this function...if it suits you... frmBaseForm frmLoad= new frmBaseForm(); ShowMdiChild(frmLaod); private void ShowMdiChild(Form frm) { if(frm==null) return; for(int i = 0 ; i < this.MdiChildren.GetLength(0) ; i++ ) if(this.MdiChildren[i].Name.Equals(frm.Name)) return; //if (! this.Contains(frm)) frm.MdiParent = this; frm.Show(); } sorry for my bad English.
-
Use this function...if it suits you... frmBaseForm frmLoad= new frmBaseForm(); ShowMdiChild(frmLaod); private void ShowMdiChild(Form frm) { if(frm==null) return; for(int i = 0 ; i < this.MdiChildren.GetLength(0) ; i++ ) if(this.MdiChildren[i].Name.Equals(frm.Name)) return; //if (! this.Contains(frm)) frm.MdiParent = this; frm.Show(); } sorry for my bad English.
thnx a lot,its working fine