MyControl:UserControl { protected override OnLoad(EventArgs e) { if(!DesignMode) //如果不处于“设计时” { //操作注册表 //连接数据库 } } }