Dig*_*lla 5 c# events panel scrollbar winforms
我有一个winform应用程序,我希望在滚动条到达面板底部时触发事件.
我试过这个:
private void Panel1_Scroll(object sender, ScrollEventArgs e)
{
//some operation
}
Run Code Online (Sandbox Code Playgroud)
但是每当我滚动滚动条时它都是触发事件,而不是在我到达终点时.
怎么做到这一点?
检查ScrollEventArgs.NewValue财产。像这样:
private void Panel1_Scroll(object sender, ScrollEventArgs e)
{
if (e.NewValue == panel1.VerticalScroll.Maximum - panel1.VerticalScroll.LargeChange + 1)
{
if(e.NewValue != e.OldValue) // Checking when the scrollbar is at bottom and user clicks/scrolls the scrollbar
{
MessageBox.Show("Test"); // Some operation
}
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1154 次 |
| 最近记录: |