交互式设计时用户控制
如果标题令人困惑,我深表歉意,我花了近 5 分钟才最终想到这个标题...
好吧,您知道如何在 Visual Studio Express 中将 TabControl
添加到表单中,然后您可以单击 TabControl
右上角的右箭头,它会添加一个新的 TabPage
,还是删除一个?
好吧,我正在创建一个用户控件,我需要人们能够在面板之间切换(我的用户控件由多个面板组成)。我知道这是可能的,因为我过去使用过功能区Control
,并且您可以在设计器视图中添加新按钮等。
有人可以就我如何实现这一目标提供任何建议/建议吗?
谢谢
I apologise if the title was confusing, it took me nearly 5 minutes to finally think of a title for this one...
Okay, you know how in Visual Studio Express when you add a TabControl
to the Form, and you can click on the right-arrow on the top right of the TabControl
and it will add a new TabPage
, or remove one?
Well, I'm creating a User Control
where I need people to be able to switch between Panels (my user control is made up of several Panels). I know this is possible as I've used a Ribbon Control
in the past and you could add new buttons etc in the Designer View.
Can somebody please provide any suggestions/advice on how I might go about acheiving this?
Thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果我正确理解你的问题,你正在谈论智能标签。
该过程有点复杂,因此我不会尝试发布完整的示例。相反,我会建议您参阅有关该主题的本教程。长话短说,您必须创建一个自定义设计器,并注册一个或多个自定义操作。您可以使用它创建一个列出可用面板的组合框,并在所选项目更改时在它们之间切换。
(注意 - 术语“智能标记”在 Visual Studio 中具有两种不同的含义 - 我具体讨论的是可视化设计器智能标记,而不是代码编辑器中的智能标记)。
If I understand your question correctly, you're talking about smart tags.
The process is a little bit involved, so I'm not going to try to post a complete sample. Instead, I'll refer you to this tutorial on the subject. To make a long story short, you have to create a custom designer, and register one or more custom actions. You can use this to create a combo box listing the available panels and switch between them when the selected item is changed.
(Note - the term "smart tags" has two distinct meanings in Visual Studio - I'm specifically talking about the visual designer smart tags, not smart tags in the code editor).
当您创建一个从
Control
继承的控件时,您必须使用几个属性,例如IsDesignMode
,然后您可以构造事件处理程序,特别是在设计模式中:假设控件有一个诸如
MouseClick
的事件,你可以这样做:另一个我能想到的是'ShouldSerialize' 后跟可公开访问的属性,以便将该属性保留到设计器生成的代码中,例如假设 Control 有一个布尔值property
Foo
如果
ShouldSerializeFoo
返回 false,则没有属性被持久化,当 true 时相反,它将被隐藏在 Form.Designer.cs 代码中...希望这有帮助,
此致,
汤姆.
When you make a control that is inherited from
Control
, you have to make use of a couple of properties such asIsDesignMode
, you can then construct event handlers especially for within Design Mode:Suppose the control has an event such as
MouseClick
, you can do this:Another I can think of is 'ShouldSerialize' followed by a publicly accessible property in order to persist the property to the designer-generated code, suppose for example a Control has a boolean property
Foo
If
ShouldSerializeFoo
returned false, no property is persisted, its the opposite when true, it will be buried within the Form.Designer.cs code...Hope this helps,
Best regards,
Tom.