I am creating a Windows application and I have a TabControl control with some other non-interactive controls above it. On the TabControl there are buttons that trigger an event. The problem that I am having is that whenever I go from clicking a button to clicking the TabControl, the AutoScroll position on my main panel changes so that the TabControl is at the very top of the visible area of the form (it should be the non-interactive controls at the top).
I had this problem immediately when loading the form, and I fixed it using this line in the Form1_Shown event:
Panel1.AutoScrollPosition = New Point(0, 0)
I have been trying to use this line of code in other events such as Button1_LostFocus, TabControl1.GotFocus, TabControl1_Click, TabControl1_Selected with moderate success in the TabControl1_Selected event. However, the AutoScroll still changes when I select the same tab that the button is on, after clicking the button. Also, if I select a different tab after clicking the button, it changes very quickly, as if it changes before the TabControl1_Selected event fires.
Any help would be appreciated on how to fix the position changing on the AutoScroll property!