C#多屏显示单个窗体 [英] C# Multiple Screen View Single Form

查看:127
本文介绍了C#多屏显示单个窗体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了C#中的GUI应该是这样的:

I created a GUI in C# which should look like this:

在主屏幕有两个按钮,当 Button1的点击我不想用打开一个新的形式 form2.show(); ,但同时保持相同的形式我想改变显示

On Main Screen there are two Buttons, When Button1 is clicked I don't want to open a new form using form2.show(); but while staying in the same form I want to change display.

我这样做是使用隐藏GUI元素和显示要求的其他内容。

I did this using hiding GUI elements and showing the other elements as required.

它正常工作,因为我想,但在 Form1中设计师查看我不得不创建凌乱的图形用户界面。

It works fine as I wanted but in the designer View of Form1 I had to create messy GUI.

我的问题是它良好的编程习惯或不?如果没有,那么什么是实现这一目标的最佳或推荐的方式。

My question is that is it good programming practice or not? If not then what is the best or recommended way to achieve this.

感谢

推荐答案

您可能要考虑一个Tabless选项卡上的控制,我倾向于使用它们了很多我的工作这些天,因为它很容易和快速的使用与他们双赢的窗体设计器建立一个接口。

You might want to consider a 'Tabless' tab control, I tend to use them for a lot of my work these days as it's easy and quick to build an interface using the win-forms designer with them.

    class TablessTabControl : TabControl
    {
        protected override void WndProc(ref Message m)
        {
            // Hide tabs by trapping the TCM_ADJUSTRECT message
            if (m.Msg == 0x1328 && !DesignMode) m.Result = (IntPtr)1;
            else base.WndProc(ref m);
        }
    }

这将延长标签控件并沿隐藏标签顶部,然后你可以通过编程使用类似于下面的代码更改标签:

This will extend the tab control and hide the tabs along the top, you can then change tab programmatically by using code similar to the following:

    tablessTabControl.SelectTab("tabName");

这是不是我的原创作品,我发现它漂浮在网络上而回,并能'不记得在那里我看到了它。无论如何,我希望这可以帮助!

This isn't my original work, I found it floating around the web a while back and can't remember where I saw it. Anyway I hope this helps!

这篇关于C#多屏显示单个窗体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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