C# UserControl.VerticalScroll.Value not being set

后端 未结 4 1413
野趣味
野趣味 2020-12-20 21:00

I\'ve got a chunk of C# code that is supposed to set VerticalScroll.Value within a class that inherits from UserControl. It gets called when any child object of the class c

4条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-20 21:54

    I was having the same problem and came upon the solution in some dev forum. After setting the VerticalScroll.Value, you have to call PerformLayout() to make the scrolling control update. So do this:

    scrollingcontrol.VerticalScroll.Value = top;
    scrollingcontrol.PerformLayout();
    

    This makes more sense than setting .Value twice, though it seems to have the same effect.

提交回复
热议问题