Results 1 to 2 of 2

Thread: mdi form problem

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Feb 2004
    Posts
    29

    mdi form problem

    Code:
    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?
    Arvinder Gill

  2. #2
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Code:
    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();*/
    }
        }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width