C#中的Treeview和面板,案例转到下一个表单 [英] Treeview and panel in C#, case go to next form
问题描述
我正在尝试使用treeview和Panel制作桌面应用程序,它可以正常工作。但是,当我尝试不改变时,例如,如果我单击帐户开放,它打开表单,但如果我单击以转到应用程序内的其他表单它不会更改,您必须重新启动表单以移动到主应用程序中的另一个表单我的源代码如下所示:
I am trying to make a desktop application using treeview and Panel it works fine a bit. But when i try to does not change like for instance, if i click Account opening, it opens the form, but if i click to go to a different form inside the application it doesnt change , you have to restart the form again to move to another form inside the main application My source code looks like this :
private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
{
switch (e.Node.Text)
{
case "Account Opening":
f = new AccountOpening();
f.TopLevel = false;
this.panel1.Controls.Add(f);
f.Dock = DockStyle.Fill;
f.Show();
break;
case "Check Balance":
f = new CheckBalance();
f.TopLevel = false;
this.panel1.Controls.Add(f);
f.Dock = DockStyle.Fill;
f.Show();
break;
case "Deposit":
f = new Deposit();
f.TopLevel = false;
this.panel1.Controls.Add(f);
f.Dock = DockStyle.Fill;
f.Show();
break;
case "Loan Repayment":
f = new LoanRepayment();
f.TopLevel = false;
this.panel1.Controls.Add(f);
f.Dock = DockStyle.Fill;
f.Show();
break;
case "Transfers":
f = new Transfers();
f.TopLevel = false;
this.panel1.Controls.Add(f);
f.Dock = DockStyle.Fill;
f.Show();
break;
case "Withdrawal":
f = new Withdrawal();
f.TopLevel = false;
this.panel1.Controls.Add(f);
f.Dock = DockStyle.Fill;
f.Show();
break;
}
}
显然我缺少什么?
我尝试了什么:
我用过If和简单的开关盒,似乎没什么用正如我所期待的那样
Apparently what am i missing?
What I have tried:
I have used If and simple switch case, doesnt seem to work as i expect
推荐答案
使用Treeview& Windows窗体中的面板控件 [ ^ ]
如果有帮助,请投票选择解决方案
Using Treeview & Panel control in Windows Form[^]
If this helps please vote for the solution
这篇关于C#中的Treeview和面板,案例转到下一个表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!