关于winform的UserControl的问题 在什么地方指定父控件?我是直接在属性编辑器上对ToolBar进行增加ToolButton的。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 看看DesignerSerializationVisibilityAttribute的帮助 Jim3具体应该怎么用?msdn上面写的不是很明确。 public class MyUserControl: System.Windows.Forms.UserControl{ private System.Windows.Forms.ToolBar toolBar1; public ToolBar TBar { get{return new toolBar1;} set{toolBar1 = value;} }} public ToolBar TBar{get{return toolBar1;}//set{toolBar1 = value;} 不需要set属性。} lonestar5555和jimh你们说的都不对。jim3说的应该是对的。。但是我不知道具体怎么使用。 晕我的代码都贴出来了啊。。就是那些。。那是用户控件的代码,其他的就是把用户控件放到窗体上。然后通过属性编辑器对这个用户控件上的ToolBar进行增加ToolBarButton。你试一下就知道结果了。 [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] public ToolBar.ToolBarButtonCollection Buttons { get{return toolBar1.Buttons;} }我现在测试出。在UserControl里面再增加一个这样的属性。就能达到我的要求了。加到窗体上以后的生成的代码是这样的 this.myUserControl = new myUserControl(); this.toolBarButton19 = new System.Windows.Forms.ToolBarButton(); this.toolBarButton20 = new System.Windows.Forms.ToolBarButton(); this.myUserControl.Buttons.AddRange(new System.Windows.Forms.ToolBarButton[] {this.toolBarButton19, this.toolBarButton20});已经达到了我要的结果。但是。最后一条语句不理想。我觉得应该是this.myUserControl.TBar.Buttons.AddRange(new System.Windows.Forms.ToolBarButton[] {this.toolBarButton19, this.toolBarButton20});有什么办法搞定? 有时并不能完全依赖IDE的设计时功能,这个功能是有限的.如果不是一定要这么做,就换一个思路吧. tryhttp://www.csdn.net/develop/Read_Article.asp?id=24936http://www.csdn.net/develop/Read_Article.asp?id=24937http://www.csdn.net/develop/Read_Article.asp?id=24938http://www.csdn.net/develop/Read_Article.asp?id=24939 SQL Server 数据库怎么批量添加? 为什么总提示找不到存储过程? 求拆分身份证住址的方法 关于企业库里cache application block的问题(急,谢谢) 打扰一下。。 怎么写自己网站的关键词啊?多个关键词 用Assembly 调用到的dll文件后,这个文件就一直被占用,怎么解决? 关于窗体的问题,谢谢! 在c#.net里边如何实现类似于指针的功能? 跨项目如何进行测试??? 三层开发关于DA层的错误处理!可以讨论讨论 怎样象任务管理器那样的得到进程是用户进程还是系统进程 求救,有关SharpDevelop的问题
{
private System.Windows.Forms.ToolBar toolBar1;
public ToolBar TBar
{
get{return new toolBar1;}
set{toolBar1 = value;}
}
}
{
get{return toolBar1;}
//set{toolBar1 = value;} 不需要set属性。
}
jim3说的应该是对的。。但是我不知道具体怎么使用。
你试一下就知道结果了。
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public ToolBar.ToolBarButtonCollection Buttons
{
get{return toolBar1.Buttons;}
}
我现在测试出。在UserControl里面再增加一个这样的属性。就能达到我的要求了。
加到窗体上以后的生成的代码是这样的
this.myUserControl = new myUserControl();
this.toolBarButton19 = new System.Windows.Forms.ToolBarButton();
this.toolBarButton20 = new System.Windows.Forms.ToolBarButton();
this.myUserControl.Buttons.AddRange(new System.Windows.Forms.ToolBarButton[] {this.toolBarButton19, this.toolBarButton20});
已经达到了我要的结果。
但是。最后一条语句不理想。我觉得应该是
this.myUserControl.TBar.Buttons.AddRange(new System.Windows.Forms.ToolBarButton[] {this.toolBarButton19, this.toolBarButton20});
有什么办法搞定?
如果不是一定要这么做,就换一个思路吧.
http://www.csdn.net/develop/Read_Article.asp?id=24936
http://www.csdn.net/develop/Read_Article.asp?id=24937
http://www.csdn.net/develop/Read_Article.asp?id=24938
http://www.csdn.net/develop/Read_Article.asp?id=24939