Visual Studio 2010: Button size changes after build

I have a C# winform project in Visual Studio 2010.  My customer complained that button text was being cut off, even after I resized the buttons.  After further testing, I found that the buttons were resizing when I build the project.

I will resize the buttons larger or smaller, but once I rebuild the project, the Form window refreshes, and the button sizes change.  The three buttons on the form always seem to resize back to a width of 75 no matter what I try.

The buttons all have Auto Size = False, and I don't have any code that modifies the button size.

In this example, I resized the button to be small:

Before Compile
After building the project, the button is back to 75 width:

After Compile
The only other detail I can find is that in the Form.Designer.cs file, there is a line to set the button size, but it's set to a width of 30, while the button gets resized to 75.

Button Designer Code
Any ideas as to what might be causing this?

Thanks,

Steve
LVL 18
Steve EndowMicrosoft MVP - Dynamics GPAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Mike EghtebasDatabase and Application DeveloperCommented:
I think this has to do with the image property (like zoom, crop, etc.). I am testing it now to give you more information.

brb
0
Mike EghtebasDatabase and Application DeveloperCommented:
I did test in vs2012. I was able it fix it by setting Layout/auttoSize =False.

---

I also tested the same in vs2010. It works okay when I have Auto Size = False (of the button property).

I know you are saying you have already Auto Size = False I don't know why it is not working for you.

Mike
0
Steve EndowMicrosoft MVP - Dynamics GPAuthor Commented:
I just did a test with a new VS 2010 project and the problem doesn't occur.  

And I resized the buttons on another form in the real project, and the problem does not occur with that form.

So it seems to be an issue with the main form only.

The one thing I notice is that when I have the main form visible and build the project, as soon as VS is done, the main form redraws, and that is when the buttons resize.  I flashes briefly.  The other form in the project doesn't do that--it stays visible and doesn't change or refresh.

I guess I must have something in the form that is causing the issue, or something about the form data is messed up.

I'll keep looking.
0
Steve EndowMicrosoft MVP - Dynamics GPAuthor Commented:
I've spent too much time dealing with such a stupid little problem that I've given up.  Instead of fighting with Visual Studio on the design time issue, I've just added code on Form Load to fix it at run time.

            btnTimer.Width = 23;
            btnTimer.Location = new Point(761, 126);

            btnUnselectAll.Width = 85;
            btnUnselectAll.Location = new Point(459, 121);

Open in new window


This works fine--the button widths and positions appear properly at run time.

Lame, but it would probably take me 10 hours to figure out the problem or rebuild the form from scratch to try and eliminate the issue.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Steve EndowMicrosoft MVP - Dynamics GPAuthor Commented:
Unable to find a solution, so I came up with a workaround.  Thanks for the assistance.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.