I am developing a WinForms application in which there is a panel which contains some user-controls. When the panel loads for the first time it shows 10 user controls. But when it is scrolled down completely it should load and append more user controls at the end of the panel. I am trying to achieve this using this code:
private void topicContainer_Scroll(object sender, ScrollEventArgs e)
{
if (e.NewValue== topicContainer.VerticalScroll.Value)
MessageBox.Show("Topics load here");
}
Its just a trial. I don't know what actually this NewValue means. So, can you please tell how to accomplish my this task?
MSDN covers the case quite nicely. Have you checked it out?
Remember though about the weird behavior of scrollbars: user is never able to reach its
Maximum
value. Read remarks in the ScrollBar.Maximum MSDN help page.As others have mentioned, the scrollbar never does reach its Maximum value, and that is due to the LargeChange property getting factored into the equation:
The
+ 1
is for the zero-based offset. If you set the AutoScrollMinSize height property to 500, the Maximum value is actually 499.This function must be placed in a static class.