的WinForms - 如何显示在设计/隐藏要素? [英] Winforms - how to show/hide elements in designer?

查看:150
本文介绍了的WinForms - 如何显示在设计/隐藏要素?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图让使用的WinForms多页的应用程序。我decied使用多个小组 - 每个小组再presents不同的页面,这样我就可以在它们之间进行切换时,我需要显示不同的内容

I am trying to make a multiple page application using winforms. I decied to use multiple Panels - each panel represents different page, so I can switch between them when I need to display different content.

我的问题是关于设计视图叠加面板。当我有2+全屏幕面板,他们所有的堆栈彼此,我不能看到我前面创建的。有没有什么解决办法?改变可视性不会影响设计者图。把它看成是一个Photoshop般的选项,以显示/隐藏层。我使用Visual C#2010例preSS。

My problem is about stacking panels in designer view. When I have 2+ full screen panels, they all stack on each other and I can't see the one that I created earlier. Is there any solution to this ? Changing visibility does not affect designers view. Think of it as a photoshop-like option to show/hide layers. I'm using Visual C# 2010 Express.

在此先感谢, 卡米尔

推荐答案

在这里有几个选项:

  1. 使用文档大纲视图(查看 - >其他窗口 - >文档大纲)以选择您所关心的面板。它可以右键单击并选择置于顶层来把它放在一切的面前。
  2. 虽然它可能不相关的,你在做什么,你可能会考虑使用的TabControl ,你可以乱用直观的设计时间。这是,如果你希望你的用户能够他们正在查看哪个面板手动更改只是一个合理的解决方案。
  3. 在考虑单独对他们的移动你的面板到自定义用户控件类和工作。如果这些面板的内容和逻辑是合理的自包含的,那么你可能要做到这一点无论如何只是为了更好地调整你的code。
  1. Use the Document Outline view (View --> Other Windows --> Document Outline) to select the panel you care about. You can right-click on it and choose Bring to Front to put it in front of everything else.
  2. Though it's probably not relevant to what you're doing, you might consider using a TabControl, which you can mess with visually at design time. This is only a reasonable solution if you want your users to be able to manually change which panel they're viewing.
  3. Consider moving your panels into custom UserControl classes and work on them separately. If the content and logic of these panels is reasonably self-contained then you may want to do this anyway just to better restructure your code.

附录:您还可以使用一劈,使一个的TabControl 的标签对用户不可见。将一个的TabControl 的形式,并在运行时设置 ItemSize 高度1。这使得它(几乎)无法为用户更改自己的标签,但仍允许您更改设计器中的可见标签。


Addendum: You can also use a hack that makes a TabControl's tabs invisible to the user. Put a TabControl on your form, and at run-time set the ItemSize height to 1. This makes it (almost) impossible for the user to change the tabs on their own, but still allows you to change the visible tab in the designer.

myTabControl.ItemSize = new Size(myTabControl.ItemSize.Width, 1);

请注意,我称之为一个的破解的是有原因的:的TabControl 取值并不意味着要使用这种方式。它的出现为工作的东西,但像所有的黑客可能会在任何时间,所以你应该只做到这一点作为最后的手段(如果它会导致头痛以后不要怪我......)打破。总之,我的不要推荐这个黑客,我只是它提供的是一种可能性。

Note that I called this a hack for a reason: TabControls were not meant to be used this way. It's something that appears to work, but like all hacks it may break at any time so you should only do it as a last resort (and don't blame me if it causes headaches later on...). In short, I do not recommend this hack, I only offer it as a possibility.

这篇关于的WinForms - 如何显示在设计/隐藏要素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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