Wednesday, June 18, 2008

Scrollbar issue with .Net

The behavior of scrollbars in container controls like Panel in .Net does raise the question of whether it’s a bug.

Scroll down the scrollbar to the bottom and attempt to bring it to top most position using code.

panel1.VerticalScroll.Value = 0;

This would definetly make the contends of the control to be scrolled up, how ever, if you notice the scrollbar associated with the control is still in that topmost position.

The only available workaround is to assign the VerticalScroll.Value twice.

panel1.VerticalScroll.Value = 0;
panel1.VerticalScroll.Value = 0;

Its quite shocking that this bug, which was seen in .Net 2005, hasn’t been fixed in .Net 2008.