110,534
社区成员
发帖
与我相关
我的任务
分享
public Form1()
{
InitializeComponent();
this.BackColor = Color.Blue;
SimpleUserControl simpleUserControl = new SimpleUserControl
{
Parent = this,
Dock = DockStyle.Fill
};
}
}
class SimpleUserControl : UserControl
{
public SimpleUserControl()
{
Button button = new Button
{
Parent = this,
Dock = DockStyle.Top,
};
Panel panel = new Panel
{
Parent = this,
BackColor = Color.Red,
Dock = DockStyle.Top
};
button.Click += (sender, e) =>
{
panel.Visible = !panel.Visible;
};
this.AutoSize = true;
}
}