我有一个winform应用程序,我希望在滚动条到达面板底部时触发事件.
我试过这个:
private void Panel1_Scroll(object sender, ScrollEventArgs e)
{
//some operation
}
但是每当我滚动滚动条时它都是触发事件,而不是在我到达终点时.
怎么做到这一点?
解决方法:
检查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
}
}
}