Solved

Visual Studio 2010: Button size changes after build

Posted on 2014-11-07
5
497 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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

706 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

20 Experts available now in Live!

Get 1:1 Help Now