2012-09-05 3 views
0

를 사용.NET SplitContainer가 나는 C#을 윈도우 응용 프로그램에서 SplitContainer가 도구를 사용하고 C#을

내가

나는이 어떻게 할 수있는

splited 컨테이너 패널에서 다른 형태에 대해 하나의 양식을 대체 할

? 내가 From1 작품에서하고 싶은

은 ... 작동하고 From2 보여 .. splited 컨테이너 패널의 같은 장소를 교체 완료

하지만이 코드가 작동하지 않습니다 ...

public partial class Parent : Form{public Parent() 
{ 
    InitializeComponent(); 
} 


private void treeView1_AfterSelect(object sender, TreeViewEventArgs e) 
{ 
    TreeNode node = treeView1.SelectedNode; 

    if (node.Text.ToString().Equals("Control1")) 
    { 
     //MessageBox.Show(node.ToString()); 
     //Control1 conr1 = new Control1(); 
     ShowForm(1); 
    } 
    else if (node.Text.ToString().Equals("Control2")) 
    { 
     //MessageBox.Show(node.ToString()); 
     //Control2 conr2 = new Control2(); 
     ShowForm(2); 
    } 

} 

public void ShowForm(int id) 
{ 
    Form childObj = null; 
    if (id == 1) 
    { 
     childObj = new Control1(); 

    } 
    else 
    { 
     childObj = new Control2(); 
    } 
    childObj.TopLevel = false; 
    childObj.Visible = true; 
    childObj.Parent = this.splitContainer1.Panel2; 

    this.splitContainer1.Panel2.Controls.Clear(); 
    this.splitContainer1.Panel2.Hide(); 
    this.splitContainer1.Panel2.Controls.Add(childObj); 
    this.splitContainer1.Panel2.Show(); 
    childObj.Show(); 
} 

public Control2() 
{ 
    InitializeComponent(); 
} 

Parent bioAdMainForm = new Parent(); 
private void button1_Click(object sender, EventArgs e) 
{ 
    //Control1 enrollmentForm = new Control1(); 
    //this.Hide(); 
    //enrollmentForm.Show(); 
    bioAdMainForm.ShowForm(1); 
} 
+7

항상 '작동하지 않음'을 설명하십시오. –

+0

패널에 양식을 추가하는 것에 대해 들어 본 적이 없다 ... 패널을 사용하는 것이 좋습니다. – Stig

+0

'SplitContainer'에'Form'을 넣으시겠습니까? 'Form' 대신에'UserControl'의 자손을 배치하십시오. – Dennis

답변

-1

당신 FormPanel에 넣을 수 없습니다. 양식은 별도의 창에 표시됩니다. 양식 대신에 UserControl 자손을 사용해야 원하는 것을 얻을 수 있습니다.

+0

하지만 그 작품에서 액세스 트리보기에서 컨트롤 ,,,하지만 컨트롤에서 아니 –

+1

@UdhayakumarM : 작품 ** 무엇 ** (코드 샘플, 제발)? – Dennis

+0

의견을 통해 표시 할 수 없습니다. –