C# winforms 有没有像“ViewStack"这样的控件?在 Flex 中? [英] Does C# winforms has a control like "ViewStack" in Flex?

查看:23
本文介绍了C# winforms 有没有像“ViewStack"这样的控件?在 Flex 中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Flex 中有 ViewStack 组件.C# 有类似的控件吗?
如果是,是哪个?如果没有,您如何创建类似的行为?

In Flex there is the ViewStack component. Does C# have a similar control?
If so, which? If not, how do you create similar behavior?

推荐答案

是的,TabControl 组件就是这样工作的.您所要做的就是隐藏选项卡.向您的项目添加一个新类并粘贴如下所示的代码.编译.将新控件从工具箱顶部拖放到表单上.选项卡在设计时仍然可见,便于编辑页面.但在运行时隐藏.使用 SelectedTab 或 SelectedIndex 属性选择视图.

Yes, the TabControl component works this way. All you have to do is hide the tabs. Add a new class to your project and paste the code shown below. Compile. Drop the new control from the top of the toolbox onto your form. The tabs are still visible at design time, makes it easy to edit the pages. But hidden at runtime. Use the SelectedTab or SelectedIndex property to select the view.

using System;
using System.Windows.Forms;

class ViewStack : 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);
  }
}

这篇关于C# winforms 有没有像“ViewStack"这样的控件?在 Flex 中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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