Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Visual Studio 2010: Button size changes after build

Posted on 2014-11-07
5
Medium Priority
?
786 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 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 2000 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

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Question has a verified solution.

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

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
High user turnover can cause old/redundant user data to consume valuable space. UserResourceCleanup was developed to address this by automatically deleting user folders when the user account is deleted.
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Enter Foreign and Special Characters Enter characters you can't find on a keyboard using its ASCII code ... and learn how to make a handy reference for yourself using Excel ~ Use these codes in any Windows application! ... whether it is a Micr…
Suggested Courses

564 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