C# winforms 在 Flex 中是否有像“ViewStack”这样的控件?

Mys*_*rth 2 c# apache-flex layout viewstack winforms

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

Han*_*ant 5

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

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);
  }
}
Run Code Online (Sandbox Code Playgroud)