Solved

Visual Studio 2010: Button size changes after build

Posted on 2014-11-07
5
533 Views
Last Modified: 2014-11-13
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
0
Comment
Question by:Steve Endow
  • 3
  • 2
5 Comments
 
LVL 33

Expert Comment

by:Mike Eghtebas
ID: 40429766
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
 
LVL 33

Assisted Solution

by:Mike Eghtebas
Mike Eghtebas earned 500 total points
ID: 40429781
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
 
LVL 18

Author Comment

by:Steve Endow
ID: 40429852
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
 
LVL 18

Accepted Solution

by:
Steve Endow earned 0 total points
ID: 40430331
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
 
LVL 18

Author Closing Comment

by:Steve Endow
ID: 40439501
Unable to find a solution, so I came up with a workaround.  Thanks for the assistance.
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now