ObjectSharp Blogs

You are currently viewing

Dan's Blog

Junior's Thoughts on all Things .NET


VS.NET Inherited Forms Bug

VS.NET Bug. I was asked to look into a problem last week involving some moving buttons in the designer. The problem was occurring in inherited forms where the parent form contained some protected, and anchored controls. When you resized the child form in the designer and build, Vs.Net would create some interesting locations and sizes, often time off the form entirely. These location and size values are set in the InitializeComponent() which makes things difficult.

So, after some searching and digging I found an interesting KB article, that explains its a bug.
However Microsoft's solutions are actually the causes in VS.NET 2003.
Basically there are a few options:
  • Once you have the controls have been moved, delete the offending locations and sizes from the InitializeComponent() and they will inherit their values from the parent again.
  • Create another size and location property and replace the erroneous values with these hard coded values after InitializeComponent().
  • Change the protection level to Friend.


    Obviously some of these solutions have their own problems, but the bug is fixed in the latest beta release of Whidbey so just bide your time for a bit.
  • Comments

    • dan May 8, 2004 6:44 PM

      Hi Dan, I found your blog. How about some more posts?

      DGG

    • dan July 20, 2005 2:41 PM

      How about this for a bug. Create 2 forms Form1 and Form2.
      Inherit Form2 from Form1 create a KeyDown event handler on Form2 it never gets fired. If anyone has a solution please email mme at jtwomley@gmail.com

    Anonymous comments are disabled