如何创建动态面板中显示和隐藏在C#中使用组合框的区别选择? [英] How do I create dynamic panel to be shown and hide using difference choices in combo box in C#?
问题描述
我想使一个GUI这是动态的,这意味着在GUI将取决于哪个用户进行组合框的选择改变。
I want to make a GUI which is dynamic, meaning that the GUI will change depending on the choice which user makes on the combo box.
例如,如果组合框由{英语,西班牙语,法语},组合框底部的面板将根据选择的描述语言改变。
For example, if combo box consists of {English, Spanish, French}, the panel on the bottom of the combo box will change its description language depending on the choice.
要做到这一点,我相信我有做的是这样清晰面板,然后重绘面板,但我不知道怎么样。
To do this, I believe I have to do something like clear panel then redraw panel, but I have no idea how.
有人能告诉我如何做到这一点在Visual Studio中的细节2005年C#?
Can someone tell me how to make this happen in details on Visual Studio 2005 C#?
感谢您提前。
推荐答案
我有这个确切的实现就在这里: http://nbug.codeplex.com/SourceControl/changeset /浏览/ 6081#107027 它实现了IPanelLoader(ISubmitPanel我的情况)接口,并加载与在组合框中的任何同名面板。基本上,下载源代码,编译并看看在配置项目。有很多的事情,会带我的网页来解释,但已经有一个完全成熟的例子。
I have this exact implementation right here: http://nbug.codeplex.com/SourceControl/changeset/view/6081#107027 which implements an IPanelLoader (ISubmitPanel for my case) interface and loads any panel with the same name of that in a combo box. Basically download the source code and compile it and have a look at the "Configurator" project. There are a lot of things which would take me pages to explain but there is already a full blown example.
在我的情况下,任何形式实施 ISubmitPanel
接口(MailForm,FtpForm在我的情况等),可以加载这样的:
In my case, any form implementing the ISubmitPanel
interface (MailForm, FtpForm etc. in my case) can be loaded like this:
private void SubmitComboBox_SelectedIndexChanged(object sender, EventArgs e)
{
switch (this.submitComboBox.SelectedItem.ToString())
{
case "E-Mail":
this.Controls.Add(new MailForm());
break;
case "FTP":
this.Controls.Add(new FtpForm());
break;
case "HTTP":
this.Controls.Add(new HttpForm());
break;
}
}
Ofcourse此代码应在你想要另一种形式运行其他形式装入。
Ofcourse this code should run in another form where you want to load the other form into.
编辑:源代码是从 NBug 项目。
The source code is from NBug project.
这篇关于如何创建动态面板中显示和隐藏在C#中使用组合框的区别选择?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!