如何创建动态面板以显示和隐藏使用C#中的组合框中的差异选择? [英] How do I create dynamic panel to be shown and hide using difference choices in combo box in C#?

查看:405
本文介绍了如何创建动态面板以显示和隐藏使用C#中的组合框中的差异选择?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个动态的GUI,这意味着GUI将根据用户在组合框上的选择而改变。



例如,如果组合框由{英语,西班牙语,法语}组成,组合框底部的面板将根据选择更改其描述语言。



我相信我必须做一些事情,如清除面板然后重绘面板,但我不知道如何。



有人可以告诉我如何使这个发生在Visual Studio 2005 C#?



提前感谢。

解决方案

这里的确切实现:项目。


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.

Can someone tell me how to make this happen in details on Visual Studio 2005 C#?

Thank you in advance.

解决方案

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.

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 this code should run in another form where you want to load the other form into.

Edit: The source code is from NBug project.

这篇关于如何创建动态面板以显示和隐藏使用C#中的组合框中的差异选择?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆