winform panel动态添加控件,内容超过不显示滚动条
rt
[解决办法]
private void Form1_Load(object sender, EventArgs e)
{
AddControl();
}
public void AddControl()
{
Button button = new Button();
button.Location = new System.Drawing.Point(100, 50);
button.Name = "buttonXXX";
button.Text = "buttonXXX";
this.panel1.Controls.Add(button);
button.Click += new EventHandler(control_Click);
}
public void control_Click(object sender, EventArgs e)
{
//添加事件代码
MessageBox.Show("添加事件代码");
}
将Button换成你想要添加的控件Control,将Location 位置按需求设置一下