看到了一段比较典型的代码,估计是实现这一功能的, 先收藏一下, 有待研究
[BrowsableAttribute(false)]
public Form HostingForm
{
get
{
if ((hostingForm == null) && this.DesignMode)
{
IDesignerHost designer = this.GetService(typeof(IDesignerHost)) as IDesignerHost;
if (designer != null)
{
hostingForm = designer.RootComponent as Form;
}
}
return hostingForm;
}
set
{
hostingForm = value;
}
}