Click here to Skip to main content
15,914,417 members
Home / Discussions / C#
   

C#

 
GeneralRe: how to change diacritics color ? Pin
hdv21223-May-07 8:14
hdv21223-May-07 8:14 
GeneralRe: how to change diacritics color ? Pin
Dave Kreskowiak23-May-07 8:41
mveDave Kreskowiak23-May-07 8:41 
AnswerRe: how to change diacritics color ? Pin
Guffa23-May-07 20:55
Guffa23-May-07 20:55 
QuestionHow can I get environment variables from computer that is in network. Pin
xiamingjun23-May-07 1:49
xiamingjun23-May-07 1:49 
AnswerRe: How can I get environment variables from computer that is in network. Pin
Colin Angus Mackay23-May-07 3:12
Colin Angus Mackay23-May-07 3:12 
GeneralRe: How can I get environment variables from computer that is in network. Pin
xiamingjun23-May-07 15:36
xiamingjun23-May-07 15:36 
Questionscreen scrape Pin
nikkitech23-May-07 0:58
nikkitech23-May-07 0:58 
QuestionCentering Text on Custom Button Pin
PHDENG8123-May-07 0:57
PHDENG8123-May-07 0:57 
I am reposting to add more detail.

I have a custom button that I have created which inherits from windows.forms.button. I simply override the mouseenter, mouseover, and mousedown events to paint a custom gradient over the button. In doing so, I must redraw the available image and text. I have been able to align the image with the base. However, I am unable to do the same with the text. Specifically, centering. It is close, just not perfect.

SizeF wSize = graphics.MeasureString(this.Text, this.Font);
float wCenterX = (Width - wSize.Width) / 2;

mTextPt.X = wCenterX;//this does not work properly
mTextPt.Y = Height - 19;// this works fine

e.Graphics.DrawString(this.Text, this.Font, new SolidBrush(this.ForeColor), mTextpt);


For most of the buttons, the text shifts slightly to the left when I use any of the custom events.

I have thoroughly tried using the StringFormatter to align the text accordingly. However, I have come up empty handed. When you set the LineAlignment to place the text at the bottom of the control, there doesn't seem to be the ability to "pad" the text from the bottom. Therefore, the text simply "sits" on the base or bottom of the control and fails to align with the base text.

Any help would be greatly appreciated. Thanks.



PHD
AnswerRe: Centering Text on Custom Button Pin
Bekjong23-May-07 1:36
Bekjong23-May-07 1:36 
GeneralRe: Centering Text on Custom Button Pin
PHDENG8123-May-07 2:18
PHDENG8123-May-07 2:18 
AnswerRe: Centering Text on Custom Button Pin
andre_swnpl23-May-07 1:40
andre_swnpl23-May-07 1:40 
GeneralRe: Centering Text on Custom Button Pin
PHDENG8123-May-07 2:40
PHDENG8123-May-07 2:40 
GeneralRe: Centering Text on Custom Button Pin
Expert Coming23-May-07 9:32
Expert Coming23-May-07 9:32 
GeneralRe: Centering Text on Custom Button Pin
PHDENG8124-May-07 5:14
PHDENG8124-May-07 5:14 
QuestionSmooth motions Pin
Muammar©23-May-07 0:30
Muammar©23-May-07 0:30 
AnswerRe: Smooth motions Pin
Adam Crawford23-May-07 3:32
Adam Crawford23-May-07 3:32 
QuestionHow to include an escape char in System.Uri object Pin
hanabi41823-May-07 0:11
hanabi41823-May-07 0:11 
AnswerRe: How to include an escape char in System.Uri object Pin
blackjack215023-May-07 1:20
blackjack215023-May-07 1:20 
GeneralRe: How to include an escape char in System.Uri object Pin
Guffa23-May-07 1:38
Guffa23-May-07 1:38 
AnswerRe: How to include an escape char in System.Uri object Pin
Guffa23-May-07 1:46
Guffa23-May-07 1:46 
AnswerRe: How to include an escape char in System.Uri object Pin
Dave Herren23-May-07 3:21
Dave Herren23-May-07 3:21 
GeneralRe: How to include an escape char in System.Uri object Pin
hanabi41828-May-07 16:36
hanabi41828-May-07 16:36 
QuestionInstallation woes Pin
Colin Angus Mackay22-May-07 23:50
Colin Angus Mackay22-May-07 23:50 
AnswerRe: Installation woes Pin
andre_swnpl23-May-07 1:23
andre_swnpl23-May-07 1:23 
GeneralRe: Installation woes Pin
Colin Angus Mackay23-May-07 3:07
Colin Angus Mackay23-May-07 3:07 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.