c#如何让pannel的滚动条一直显示最下方?
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。
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询