473,685 Members | 2,581 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 15946
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
5883
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
16186
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
1128
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
13806
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
4295
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
1798
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
3062
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
2686
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
1849
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
8512
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9048
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...
1
8763
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8774
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
7591
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
6436
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
5793
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();...
0
4525
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2941
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.