public partial class Form1 : Form { int X_Value; // Stores position of Horizontal scroll bar int Y_Value; // Stores position of Vertical scroll bar public Form1() { InitializeComponent(); this.Scroll+=new ScrollEventHandler(form1_Scroll); } private void form1_Scroll(object sender, ScrollEventArgs e) { if (e.ScrollOrientation == ScrollOrientation.HorizontalScroll) { X_Value = e.NewValue; } if(e.ScrollOrientation == ScrollOrientation.VerticalScroll) { Y_Value = e.NewValue; } } private void Form2_Activated(object sender, EventArgs e) { this.AutoScrollPosition = new Point(X_Value, Y_Value); } }
解决窗体得到焦点时,滚动条复原问题
最新推荐文章于 2020-12-11 13:41:08 发布