Question

On Visual Studio 2008, I have an instance of System.Windows.Forms.TabPage.

There are many controls on the TabPage.

Therefore, there is a vertical scroll bar on the TabPage.

Numerous times, all of the controls get uniformly shifted down, making lots of empty space at the top of the TabPage. I must scroll down to view the first control, which should be at the top of the TabPage. This happens within Visual Studio and subsequently at runtime as well.

No event seems to trigger this shift. It just happens. Viewing the Location property for each control shows that they all shifted downwards by the same value.

I have had to manually fix this several times. Then the problem comes back, usually days later. I can work on the form. It looks good. Close it. Come back later, and the controls have all shifted down by a fixed amount.

July 14, more information

Visual Studio 2008 is changing this:

this.groupBoxTrees.Location = new System.Drawing.Point(3, 3);

To This:

this.groupBoxTrees.Location = new System.Drawing.Point(3, 1030);

Why? When? For what reason? I don't know.

Note the value 1030 is random too. All I can say is that for some reason VS adds a constant value to each Location.Y property on every control on a TabPage. All of the controls are locked.

Any suggestions?

Thanks!

Was it helpful?

Solution

Thanks to a colleague, I have found out what's going wrong.

If the form is saved when the scroll bar on the TabPage has been moved down, Visual Studio studio adds a number to Location.Y of every control on the TabPage. That value is correlated to the distance the scroll bar has moved down.

The problem can be prevented by always moving the scroll bar to the top of the form before saving changes made by the form.

Why does this happen? There is no way for me to find out. It may be related to the fact that I'm using two monitors. But then again, if that helps to cause the problem, then you would think that Location.X would be changed, rather than Location.Y.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top