2013-03-21 4 views
0

나는 mdi 응용 프로그램이 있습니다. 부모가 이미 새 아이 양식을 열었을 때 이미 열렸던 링크를 숨길 링크가 있습니다. 아이가 이미 열려 있는지 확인하려면 어떻게합니까?MdiChilds 숨기기/표시

A little scenario: 
link 1 -> opens Child of type A 
link 2 -> opens Child of type B 
link 3 -> open Child of type C 

Application start: 
click on link 1-> check if a child of type A is opened 

- yes -> hides the current opened child and shows the A-type Child 
- no: -> hides the current opened child and creates a new A-type child and shows it 

click on link 2 -> check if a child of type B is opened 

- yes -> hides the current opened child and shows the B-type Child 
- no: -> hides the current opened child and creates a new A-type child and shows it 

etc.. 

일부 코드는 도움이 될 수 있습니까?
는 ... 감사

UPDATE :이 같은
무엇인가?

foreach (Form aForm in this.MdiChildren) 
      { 
       aForm.Hide(); 
      } 
     foreach (Form f in this.MdiChildren) 
     { 
      if (f.Name == "VizualizareArticol") 
       f.Show(); 
      else 
      { 
       VizualizareArticol vv = new VizualizareArticol(); 
       vv.MdiParent = this; 
       vv.StartPosition = FormStartPosition.Manual; 
       vv.Location = new Point(0, 0); 

       vv.Show(); 
      } 
     } 

하지만 작동하지 않습니다 ... Control.Visible에 대한

답변

0

확인합니다. Item이 보이면 Visible이 아닌 경우 숨길 수 있습니다. 그렇지 않으면 작성한 오브젝트를보십시오.

양식을 이미 만들고 숨긴 경우 보이지 않게됩니다. 따라서 .Visible을 확인하고 양식을 표시 할 수 있습니다. 당신이 aForm.Hide와 양식을 숨길 경우

if(null != aForm && !aForm.Visible){ 
    aForm.Show() 
    aForm.BringToFront(); 
}else if(null == aForm){ 
    // create the form 
} 
// otherwise form is existing & visible 
+0

생각을 이해하지 못했다는 말했다 –

+0

그것은 보이지 않습니다. Therfore if (aForm! = null)은 if (! aForm.Visible)를 확인할 수 있습니다. – Offler