Button BorderSize Issue...

G

Guest

I have come across something that I cannot seem to find a solution for and
would like to know if anyone else has either seen the same thing and/or (even
better) has a solution.

If I set the BorderSize for a flat-style button on a Windows form, the
border is correctly drawn in the designer but it is drawn as being one pixel
wider at runtime. For example, if I set the BorderSize equal to 1, in the
designer, the border will be drawn 1 pixel wide but at runtime it will be 2
pixels wide. The only setting that seems to work like it should is a setting
of 0.

Am I missing something? Any suggestions as to why it works this way and/or
any ideas of how to fix it?

Thank you,

Jason Richmeier
 
L

Linda Liu [MSFT]

Hi Jason,

Thank you for posting.

The reason of the button's border size being drawn a little wider at
runtime is that the button gets focus. If the focus is moved to other
controls on the form, the border size of the button will be restored to 1
pixel.

Hope this helps.


Sincerely,
Linda Liu
Microsoft Online Community Support

====================================================
When responding to posts,please "Reply to Group" via
your newsreader so that others may learn and benefit
from your issue.
====================================================
 
G

Guest

Thank you for the response.

I understand what you are saying now. The reason I didn't notice the
behavior you describe before is the button was the only control on the form
that could receive focus. Once I threw a second button (which could receive
focus) on the form, the thick border went away as you described.

Something that I had tried was to derive a new class from the Button class
and override the ShowFocusCues property to always return false. This did not
appear to produce the behavior that I was looking for.

Since I could not figure out a solution to the problem, I ended up creating
a new (very specific) button class that was owner-drawn. Everything appears
to be working as I want with this button.

Thank you,

Jason Richmeier
 
L

Linda Liu [MSFT]

Hi Jason,

Thank you for your reply and the detailed additional feedback on how you
were successful in resolving this issue. Your solution will benefit many
other users.

If you have any other questions or concerns, please don't hesitate to
contact us. It is always our pleasure to be of assistance.


Sincerely,
Linda Liu
Microsoft Online Community Support

====================================================
When responding to posts,please "Reply to Group" via
your newsreader so that others may learn and benefit
from your issue.
====================================================
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top