473,796 Members | 2,524 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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:

HomeScoreNameBu tton.ForeColor = Color.Green;
HomeScoreNameBu tton.Font = new System.Drawing. Font("Tahoma",
8.50F, System.Drawing. FontStyle.Regul ar,
System.Drawing. GraphicsUnit.Po int, ((System.Byte)( 0));
this.HomeScoreN ameButton.Locat ion = new System.Drawing. Location(10,10) ;
this.HomeScoreN ameButton.Name = "HomeScoreNameB utton";
this.HomeScoreN ameButton.Size = new System.Drawing. Size(24,16);
this.HomeScoreN ameButton.Text = "Sunset";
this.HomeScoreN ameButton.TextA lign = System.Drawing. ContentAlignmen t.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 15971
I believe this has nothing to do whith C#, nor .NET WinForms. I would say
this is a Windows problem.

"Terry Brown" <tt****@gmail.c om> 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:

HomeScoreNameBu tton.ForeColor = Color.Green;
HomeScoreNameBu tton.Font = new System.Drawing. Font("Tahoma",
8.50F, System.Drawing. FontStyle.Regul ar,
System.Drawing. GraphicsUnit.Po int, ((System.Byte)( 0));
this.HomeScoreN ameButton.Locat ion = new
System.Drawing. Location(10,10) ;
this.HomeScoreN ameButton.Name = "HomeScoreNameB utton";
this.HomeScoreN ameButton.Size = new System.Drawing. Size(24,16);
this.HomeScoreN ameButton.Text = "Sunset";
this.HomeScoreN ameButton.TextA lign =
System.Drawing. ContentAlignmen t.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.c om> 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.c om> 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.c om> 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*******@cana da.com> wrote in message
news:11******** **************@ g44g2000cwa.goo glegroups.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*******@cana da.com> wrote in message
news:11******** **************@ g44g2000cwa.goo glegroups.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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
5892
by: Lea | last post by:
Hi, I 've got a problem concerning the text alignment of my three input tags. In IE6, the "login" and "ok" words are completely aligned on the bottom border. Yet my padding is : 0px 0px 0px 1px; Changing the line-height does not improve anything. In FIREFOX 0.9.3, the text of the first input tag is fine. The asterisks of the input type password are too high in text field. And finally, the text of the third input tag is on the bottom...
3
16204
by: harry | last post by:
I want to be able to change the text alignment within a table cell between "right" & "center" depending on how many rows are in the table. Is this possible in Javascript? - can't see how to do it! thanks harry
0
1140
by: Terry Brown | last post by:
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);
2
13816
by: tom | last post by:
Hi there, In IE, I am trying to govern various style attributes of a DIV tag with javascript. It's no problem doing things like this: 'window.xxx.style.top="100px";' but when I try to change the text alignment with the following: 'window.xxx.style.text-align="left";' .... I get a syntax error probably due to the hyphen.
3
4311
by: Bahman | last post by:
Hello! May be I am missing something. In the library it says the property is called 'TextAlign' or some such thing. But nothing works here like that. Is the library up to date or am I looking at the 'wrong' checkbox? Thank you for your help.
0
1806
by: VorTechS | last post by:
I'm having a problem with an inherited label, applying text rotation to aligned text. If text rotation is applied to the aligned text, the alignment goes 'nuts'. I can find no logic to what is happening. I've built the following code from several examples on the web, if you remove the rotation then alignment works fine: Imports System.ComponentModel
2
3074
by: Peted | last post by:
Are there any options to enable an antialias function on standard winform controls ? things like the displayed text on buttons , radio buttons and other standard controls look a bit jagged and stuff, is it possible to antialis the text that gets entered into the text property of the controls ?
15
2718
by: Matthew | last post by:
Hi, I'm mainly a coder, PHP at the moment, but from time to time need to design and use some css. I've a css text alignment issue. Mostly to align text neatly in the past I've used tables. But now I know I should be getting into the 21st C and using css properly. Here are 2 mock up pages with some forms on them, obviously I want the
1
1855
by: Clancyman | last post by:
Just putting together my site using Dreamweaver CS3. I have tested the page on IE and Safari locally and it is fine all Flash text and Buttons display and react as required. Once I upload the page and browse to it on line there are no flash text or buttons on the page ! Gerry
0
9679
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10453
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10223
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10003
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9050
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7546
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6785
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
3730
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2924
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.