转自:http://www.cnblogs.com/huacw/p/3967351.html
public Form3()
{
InitializeComponent();
foreach (Control gboxin groupBox1.Controls)
{
if (gboxis VScrollBar)continue;
gbox.Tag = gbox.Location.Y;
}
panelControl1.VerticalScroll.Value = panelControl1.VerticalScroll.Maximum;
}
然后加入一个垂直滚动条控件,并添加如下事件:
private void vScrollBar1_Scroll(object sender, ScrollEventArgs e)
{
foreach (Control gboxin groupBox1.Controls)
{
if (gboxis VScrollBar)continue;
gbox.Location = new Point(gbox.Location.X, (int)gbox.Tag - e.NewValue);
}
}
注意:给groupbox 的父panel设置AutoScroll=true