471,325 Members | 1,269 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,325 software developers and data experts.

text alignment and buttons

I have a problem where, depending on the text of a button, the display of
that text seems to change size or alignment.

Here is the code:

HomeScoreNameButton.ForeColor = Color.Green;
HomeScoreNameButton.Font = new System.Drawing.Font("Tahoma",
8.50F, System.Drawing.FontStyle.Regular,
System.Drawing.GraphicsUnit.Point, ((System.Byte)(0));
this.HomeScoreNameButton.Location = new System.Drawing.Location(10,10);
this.HomeScoreNameButton.Name = "HomeScoreNameButton";
this.HomeScoreNameButton.Size = new System.Drawing.Size(24,16);
this.HomeScoreNameButton.Text = "Sunset";
this.HomeScoreNameButton.TextAlign = System.Drawing.ContentAlignment.MiddleRight;

the buttons are small (24,16) for a reason, and I can't make them bigger.
when the text of the button (which changes), is too long to display, it is
simply truncated from the right.

If the button text is "Sunset Girls", then it displays as "Sunset G"
(truncated to fit), and displays properly.

However, if the text is "Sunset Boys", then it displays as "Sunset"
(truncated), which is fine, but now the "S" (capital S) loses the topmost
line of the font, as if the vertical alignment of the button text has
changed, or the size of the font has changed.

Any ideas about what is happening?

Terry Brown
www.stickmansoftware.com
Jan 13 '06 #1
7 15644
I believe this has nothing to do whith C#, nor .NET WinForms. I would say
this is a Windows problem.

"Terry Brown" <tt****@gmail.com> wrote in message
news:pa**************************@gmail.com...
I have a problem where, depending on the text of a button, the display of
that text seems to change size or alignment.

Here is the code:

HomeScoreNameButton.ForeColor = Color.Green;
HomeScoreNameButton.Font = new System.Drawing.Font("Tahoma",
8.50F, System.Drawing.FontStyle.Regular,
System.Drawing.GraphicsUnit.Point, ((System.Byte)(0));
this.HomeScoreNameButton.Location = new
System.Drawing.Location(10,10);
this.HomeScoreNameButton.Name = "HomeScoreNameButton";
this.HomeScoreNameButton.Size = new System.Drawing.Size(24,16);
this.HomeScoreNameButton.Text = "Sunset";
this.HomeScoreNameButton.TextAlign =
System.Drawing.ContentAlignment.MiddleRight;

the buttons are small (24,16) for a reason, and I can't make them bigger.
when the text of the button (which changes), is too long to display, it is
simply truncated from the right.

If the button text is "Sunset Girls", then it displays as "Sunset G"
(truncated to fit), and displays properly.

However, if the text is "Sunset Boys", then it displays as "Sunset"
(truncated), which is fine, but now the "S" (capital S) loses the topmost
line of the font, as if the vertical alignment of the button text has
changed, or the size of the font has changed.

Any ideas about what is happening?

Terry Brown
www.stickmansoftware.com

Jan 13 '06 #2
"Terry Brown" <tt****@gmail.com> wrote in message
news:pa**************************@gmail.com...
I have a problem where, depending on the text of a button, the display of
that text seems to change size or alignment.


Try setting the buttons' FlatStyle to System.

-- Alan
Jan 13 '06 #3
On Fri, 13 Jan 2006 12:03:29 -0600, Alan Pretre wrote:

Thanks! That fixes the problem.

I hesitate to ask why . . .

"Terry Brown" <tt****@gmail.com> wrote in message
news:pa**************************@gmail.com...
I have a problem where, depending on the text of a button, the display of
that text seems to change size or alignment.


Try setting the buttons' FlatStyle to System.

-- Alan


Jan 13 '06 #4
"Terry Brown" <tt****@gmail.com> wrote in message
news:pa****************************@gmail.com...
I hesitate to ask why . . .


Not sure of the reason, didn't see this problem in .NET 1.1, seems to have
arisen in .NET 2.0.

-- Alan
Jan 13 '06 #5
Are you sure that it's not attempting to wrap the next word onto the
"next line" on the button, of which there is none, and shoving the
"first line" up farther to compensate?

Jan 13 '06 #6
"Bruce Wood" <br*******@canada.com> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com...
Are you sure that it's not attempting to wrap the next word onto the
"next line" on the button, of which there is none, and shoving the
"first line" up farther to compensate?


Yes it is doing that, but it does it differently depending on that
FlatStyle. All I am saying is that the behavior has changed, I did not see
that behavior in my apps when it was built for .NET 1.1.

-- Alan
Jan 13 '06 #7
On Fri, 13 Jan 2006 15:27:24 -0600, Alan Pretre wrote:

This makes sense to me. Thanks for the discussion. If this is true
(two lines generated) then I can fix the problem my manually truncating
the string to size. I'll give it a shot.

Terry
"Bruce Wood" <br*******@canada.com> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com...
Are you sure that it's not attempting to wrap the next word onto the
"next line" on the button, of which there is none, and shoving the
"first line" up farther to compensate?


Yes it is doing that, but it does it differently depending on that
FlatStyle. All I am saying is that the behavior has changed, I did not
see that behavior in my apps when it was built for .NET 1.1.

-- Alan


Jan 14 '06 #8

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Lea | last post: by
3 posts views Thread by harry | last post: by
3 posts views Thread by Bahman | last post: by
15 posts views Thread by Matthew | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.