Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/279.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 交互式设计时用户控件_C#_Winforms_User Controls_Interactive - Fatal编程技术网

C# 交互式设计时用户控件

C# 交互式设计时用户控件,c#,winforms,user-controls,interactive,C#,Winforms,User Controls,Interactive,如果标题让人困惑,我很抱歉,我花了将近5分钟的时间才最终想到了这一个标题 好的,您知道在Visual Studio Express中,当您向表单添加TabControl时,您可以单击TabControl右上角的右箭头,它将添加一个新的TabPage,或者删除一个 嗯,我正在创建一个用户控件,我需要人们能够在面板之间切换(我的用户控件由几个面板组成)。我知道这是可能的,因为我以前使用过功能区控件,您可以在Designer视图中添加新按钮等 有人能给我提供一些建议吗 谢谢当您创建一个从控件继承的控件

如果标题让人困惑,我很抱歉,我花了将近5分钟的时间才最终想到了这一个标题

好的,您知道在Visual Studio Express中,当您向表单添加
TabControl
时,您可以单击
TabControl
右上角的右箭头,它将添加一个新的
TabPage
,或者删除一个

嗯,我正在创建一个用户
控件
,我需要人们能够在面板之间切换(我的用户控件由几个面板组成)。我知道这是可能的,因为我以前使用过功能区
控件
,您可以在Designer视图中添加新按钮等

有人能给我提供一些建议吗


谢谢

当您创建一个从
控件继承的控件时,您必须使用一些属性,例如
IsDesignMode
,然后您可以构造事件处理程序,特别是在设计模式内:

if (IsDesignMode){ // Handle the interactivity in Design mode, such as changing a property on the // Properties toolbox } 我可以想到的另一个方法是在“”后面加上一个可公开访问的属性,以便将该属性持久化到设计器生成的代码中,例如,假设一个控件有一个布尔属性
Foo

public bool Foo{ get{ return this._foo; } set{ if (this._foo != value){ this._foo = value; } } } public bool ShouldSerializeFoo(){ return true; // The property will be persisted in the designer-generated code // Check in Form.Designer.cs... } 公共图书馆{ 获取{返回此。\u foo;} 设置{if(this.\u foo!=value){ 这个。_foo=值; } } } 公共bool应该序列化foo(){ return true;//该属性将保留在设计器生成的代码中 //签入Form.Designer.cs。。。 } 如果
ShouldSerializeFoo
返回false,则不会保留任何属性,如果为true,则相反,它将隐藏在Form.Designer.cs代码中

希望这有帮助, 顺致敬意,
汤姆。

如果我没弄错你的问题,你说的是智能标签

这个过程有点复杂,所以我不打算发布一个完整的示例。相反,关于这个问题,我会让你参考。长话短说,您必须创建一个自定义设计器,并注册一个或多个自定义操作。您可以使用此选项创建一个组合框,列出可用的面板,并在所选项目更改时在它们之间切换


(注意-术语“智能标记”在Visual Studio中有两种不同的含义-我特别指的是Visual designer智能标记,而不是代码编辑器中的智能标记)。

我认为您所指的被称为“智能标记”,但我可能错了。+1@Aaronaught:nice tutorial…hhmm…priorities…*保存链接供以后使用*。。。 public bool Foo{ get{ return this._foo; } set{ if (this._foo != value){ this._foo = value; } } } public bool ShouldSerializeFoo(){ return true; // The property will be persisted in the designer-generated code // Check in Form.Designer.cs... }