给groupBox添加滚动条

 public Form3()
{
InitializeComponent();
foreach (Control gbox in groupBox1.Controls)
{
if (gbox is VScrollBar) continue;
gbox.Tag = gbox.Location.Y;
}
panelControl1.VerticalScroll.Value = panelControl1.VerticalScroll.Maximum;
}

然后加入一个垂直滚动条控件,并添加如下事件:

 private void vScrollBar1_Scroll(object sender, ScrollEventArgs e)
{
foreach (Control gbox in groupBox1.Controls)
{
if (gbox is VScrollBar) continue;
gbox.Location = new Point(gbox.Location.X, (int)gbox.Tag - e.NewValue);
}
}

注意:给groupbox 的父panel 设置AutoScroll=true

上一篇:Dynamics CRM 2013 SP1 客户表单界面上联系人subgrid上的添加现有联系人功能缺失


下一篇:五.CSS盒子模型