//将滚动条拉到最上 private void ResumeRelaCon(VerticalInfo verInfo) { foreach (Control con in relaControl.Controls) { if (con != this.vScrollBar) { con.Location = new Point(con.Location.X, con.Location.Y - verInfo.yMin); } } vScrollBar.Value = 0; }
void vScrollBar_ValueChanged(object sender, EventArgs e) { VerticalInfo verInfo = getRelaConContentInfo(); foreach (Control con in relaControl.Controls) { if (con.Name != "vScrollBar") { con.Location = new Point(con.Location.X, con.Location.Y - verInfo.yMin - vScrollBar.Value); } } }
private void AdjustVScrollBar() { VerticalInfo verInfo = getRelaConContentInfo(); ResumeRelaCon(verInfo); if (verInfo.height <= relaControl.Size.Height) { vScrollBar.Visible = false; } else { vScrollBar.SmallChange = relaControl.Size.Height / 16; vScrollBar.LargeChange = relaControl.Size.Height; vScrollBar.Maximum = verInfo.height; vScrollBar.Visible = true; } }