关于winform的UserControl的问题
我要建立一个UserControl这个UserControl上面我放了一个ToolBar,并且把他做为一个Public属性公开。
public class MyUserControl: System.Windows.Forms.UserControl
{
private System.Windows.Forms.ToolBar toolBar1;
public ToolBar TBar
{
get{return toolBar1;}
set{toolBar1 = value;}
}
}
然后我把这个UserControl放到一个Form上面。在设计期对这个Form上的UserControl的TBar属性进行设置,我增加了几个ToolButton
然后确定,运行以后。这几个ToolButton不见了。
看他的代码,他的ToolButton增加到了Form上。。但是ToolButton没有增加到ToolBar的集合中。ide没有自动生成这部分的代码
我需要在设计期对这个ToolBar进行设置,并且自动的生成相应的代码,这个问题如何解决?