C# winforms 是否有像“ViewStack”这样的控件?在伟创力?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
是的,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.
不,没有提供相同行为的标准控件。
然而,为了获得类似的行为,我只需为视图堆栈中的每个项目创建一个新的 UserControl,并将它们添加到同一位置且具有相同宽度/高度的父窗体中。
使用辅助方法可以轻松隐藏所有用户控件,然后根据输入参数显示特定的用户控件。
UserControls 的主要好处是您可以使用设计器直观地创建每个单独的堆栈项。一个可能的缺点是,如果堆栈中有很多项目,或者每个堆栈项目都很复杂,则内存使用量可能会变得相当大。
No, there is no standard control that provides the same behaviour.
However to get similar behaviour I would simply create a new UserControl for each item in the view stack and add these to a parent form at the same location and with the same width/height.
Using a helper method it is then simple to hide all user controls, and then display the specific user control based on an input parameter.
The major benefit of UserControls is that you can use the designer to visually create each of the separate stack items. A possible drawback is that if you have many items in the stack, or each stack item is complex, memory usage may become quite large.
我认为它本身不存在。您可能需要使用 Visible 属性。
I don't think it exists natively. You will probably have to play with the Visible property.