4.Flow Layout Pane
1.comboBox
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
//用switch语句实现combobox变化的响应不同的事件
switch (comboBox1.Text)
{
case"BottomUp":
flowLayoutPanel1.FlowDirection = FlowDirection.BottomUp;
break;
case"LeftToRight":
flowLayoutPanel1.FlowDirection = FlowDirection.LeftToRight;
break;
case"TopDown":
flowLayoutPanel1.FlowDirection = FlowDirection.TopDown;
break;
case"RightToLeft":
flowLayoutPanel1.FlowDirection = FlowDirection.RightToLeft;
break;
}
}
2.checkbox
private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
//实现让控件自动换行,全部可见
if (checkBox1.Checked == true)
flowLayoutPanel1.WrapContents = true;
else
flowLayoutPanel1.WrapContents = false;
}
private void checkBox2_CheckedChanged(object sender, EventArgs e)
{
// 实现滚动条
if (checkBox2.Checked == true)
flowLayoutPanel1.AutoScroll = true;
else
flowLayoutPanel1.AutoScroll = false;
}
3.添加按钮
private void button1_Click(object sender, EventArgs e)
{
Button newButton = new Button();//定义一个
newButton.Name = textBox1.Text;
newButton.Text = textBox2.Text;
flowLayoutPanel1.Controls.Add(newButton);//实现
}
浙公网安备 33010602011771号