1个回答
展开全部
//设置 滚动条 滚动到垂直滚动条最底部。
Point newPoint = new Point(0, this.panel1.Height - panel1.AutoScrollPosition.Y);
panel1.AutoScrollPosition = newPoint;
//测试用例
private void button2_Click(object sender, EventArgs e)
{
for (int i = 0; i < 10; i++)
{
Button myBut = new Button();
myBut.Name = i.ToString();
myBut.Location = new System.Drawing.Point(this.panel1.Location.X, this.panel1.Location.Y + (i * this.panel1.Height / 5));
myBut.Size = new System.Drawing.Size(this.panel1.Width, this.panel1.Height / 5);
this.panel1.Controls.Add(myBut);
}
}
private void button3_Click(object sender, EventArgs e)
{
//设置 滚动条 滚动到垂直滚动条最底部。
Point newPoint = new Point(0, this.panel1.Height - panel1.AutoScrollPosition.Y);
panel1.AutoScrollPosition = newPoint;
//同理可通过x位置信息设置滚动至水平滚动条适当位置。
//如使滚动条向右滚动了30个像素点
//newPoint = new Point(-30, 0);
//panel1.AutoScrollPosition = newPoint;
//如果滚动条滚动到起始点左侧或右侧,上部或下部,滚动条内部会自动抛弃了超出范围的值,自动取最大值或0。
}
Point newPoint = new Point(0, this.panel1.Height - panel1.AutoScrollPosition.Y);
panel1.AutoScrollPosition = newPoint;
//测试用例
private void button2_Click(object sender, EventArgs e)
{
for (int i = 0; i < 10; i++)
{
Button myBut = new Button();
myBut.Name = i.ToString();
myBut.Location = new System.Drawing.Point(this.panel1.Location.X, this.panel1.Location.Y + (i * this.panel1.Height / 5));
myBut.Size = new System.Drawing.Size(this.panel1.Width, this.panel1.Height / 5);
this.panel1.Controls.Add(myBut);
}
}
private void button3_Click(object sender, EventArgs e)
{
//设置 滚动条 滚动到垂直滚动条最底部。
Point newPoint = new Point(0, this.panel1.Height - panel1.AutoScrollPosition.Y);
panel1.AutoScrollPosition = newPoint;
//同理可通过x位置信息设置滚动至水平滚动条适当位置。
//如使滚动条向右滚动了30个像素点
//newPoint = new Point(-30, 0);
//panel1.AutoScrollPosition = newPoint;
//如果滚动条滚动到起始点左侧或右侧,上部或下部,滚动条内部会自动抛弃了超出范围的值,自动取最大值或0。
}
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询