Solved

Visual Studio 2010: Button size changes after build

Posted on 2014-11-07
5
652 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 34

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 34

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

690 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