Click here to Skip to main content
15,897,371 members
Please Sign up or sign in to vote.
2.33/5 (3 votes)
See more:
I have created a Windows form with standard controls and a custom control
(Windows 7 (64), Visual Studio 2010, VB.Net).

When I start the form in normal state, everything is OK. When I first maximize everything still is OK. When I go back tot normal again, then the standard controls that are anchored to the bottom or to the right are not displayed on the correct positions anymore. They become scattered all over the form.

When I maximize again it becomes even a bigger chaos and when I repeat this a couple of times they may even be gone completely out of sight.

This also happens when I call another sub form and return back to his main form.

The problem only appears in combination with custom controls. The controls that are part of the custom control (with anchoring to the right or to the bottom) are all functioning correct inside this custom control.

I know this must be some kind of a bug, because I have seen others too with this problem on the internet, but I cannot find a good answer anywhere.

Please, do respond only if you have encountered this problem yourself and when you have found a good solution.

Thanks in advance,
Wietze
Posted
Updated 8-Sep-14 1:19am
v2
Comments
Sergey Alexandrovich Kryukov 8-Sep-14 10:13am    
There can be too many way to screw up things. How can we know your way? Could you create some highly simplified but comprehensive code sample showing your problem?
—SA
Sergey Alexandrovich Kryukov 8-Sep-14 10:31am    
One little advice: try to prefer using Dock and Padding properties over using of the Anchor. It is not a solution of your particular problem, just a way to make the design easier and more regular.
—SA

1 solution

Sergey, I do not see why I should not use anchoring. If it is not the right
way to do things, then why did Microsoft include this beautiful method in VB ?

I did some more experimentation. I docked the custom control in a panel etc. but always the same trouble. Finally I made a workaround and recalculated the location of the controls that went berserk in the Form SizeChanged. Case solved for me.
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900