Button's text not centering???

gtzpower

Newcomer
Joined
Jan 22, 2004
Messages
12
Strange problem here. If i create a button (in C# or VB) the text won't TRUELY center unless the "flatStyle" property is set to "System" for that button. Does anyone know why this is? It only seems to do this when the text is so long (for example "Change Account Number"). Try it in your IDE, i am sure it will happen. This doesn't seem promising for a newbie to .net.
 
Centre

It only moves the text slightly when you change from 'flat' etc. to 'System.'

Isn't this because 'system' appears in 3D and therefore some of the object is used for shading, not the actual front of the button.
 
I don't think so. "Standard" is also 3D, but that is off centered too. Here's a quick example i whipped up:
 

Attachments

Here is a complete...OMG stab in the dark..

Is it something to do with the actual font being used? Try using courier new and see the result.
 
Hey, thanks. I tried aerial last night, and it did the same thing, so i didn't think it was the font, but Courier works nicely. Is there a fix? I like the ms font, but alas, i am not totally held down to using "System" style buttons.
 
I think it has something to do with proportional fonts or something? This I think is where in a given font it spaces the letters evenly, W I for example.

Not sure if thats a good explanation but I think it is close:)
 
true type fonts (as most are today) are unevenly spaced so that they will look nicer according to whatever rules they were created. On the other hand monotype fonts such as courier new have a fixed length for each character (as was on a typewriter block)
 
Um... the fact is that when you use the Standard flatstyle, the .Net framework is rending your button and when you use the System flatstyle, windows is rendering your button. The difference is between who is rendering it, not the fonts. If you say that it is off center only when it is too long, it may be a minor bug in the .net framework, and yes, this may only occur with certain fonts or by something like roundoff error when cleartype is on or something. My guess is that it is always slightly off center (again, perhaps only with certain fonts) and the off-centerness is only noticable when the string is long enough that it reaches close to the left and right edges of the button.
 
Back
Top