For whatever reasons Microsoft made detecting scrolling to bottom, and to right, in Windows Forms, much more tricky than was necessary.
The Panel has serious flaws in its scrolling behavior: the ScrollEventArgs.Type field which should hold an enumeration value of Type ScrollEventArgs is (according to Kornfeld Peter's recent source code examination) not really implemented.
private void panel1_Scroll(object sender, ScrollEventArgs e)
{
VScrollProperties vsp = panel1.VerticalScroll;
int scrollmax = vsp.Maximum - vsp.LargeChange + 1;
if (e.NewValue == scrollmax) scrolledToBottom(e.NewValue, scrollmax);
}
private void scrolledToBottom(int nv, int smax)
{
Console.WriteLine("scrolled to bottom: {0} {1}", nv, smax);
}
Note:
You could create variables at Form level, to hold the values of the Panel's VerticalScroll.Maximum and VerticalScroll.LargeChange, then initialize them in the Form Load Event, or the constructor of the Form if you don't manipulate those properties in your code ... or, if you do manipulate them, you'll need to update the variables.