text alignment and buttons

  • Thread starter Thread starter Terry Brown
  • Start date Start date
T

Terry Brown

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
 
I believe this has nothing to do whith C#, nor .NET WinForms. I would say
this is a Windows problem.
 
Terry Brown said:
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
 
On Fri, 13 Jan 2006 12:03:29 -0600, Alan Pretre wrote:

Thanks! That fixes the problem.

I hesitate to ask why . . .
 
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?
 
Bruce Wood said:
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
 
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
 

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

Back
Top