473,395 Members | 1,474 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

C#, Size of Text

Hi.

I want to center text of labels, but don't know how to do it.

I have try to do a :
distX = netUseGroupBox.ClientSize.Width / 4 - mailLabel.Text.Length * 8 / 2;

But it works only for one Label (not the others).

So, how is it possible to know the effective size of the text (size in
pixels) ?
Jul 21 '05 #1
6 7967
Mathieu Chavoutier <No****@NoSpam.org> wrote:
I want to center text of labels, but don't know how to do it.

I have try to do a :
distX = netUseGroupBox.ClientSize.Width / 4 - mailLabel.Text.Length * 8 / 2;

But it works only for one Label (not the others).

So, how is it possible to know the effective size of the text (size in
pixels) ?


Any reason not to set the TextAlign property on the label to
ContentAlignment.MiddleCenter?

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Jul 21 '05 #2
Mathieu Chavoutier <No****@NoSpam.org> wrote:
I want to center text of labels, but don't know how to do it.

I have try to do a :
distX = netUseGroupBox.ClientSize.Width / 4 - mailLabel.Text.Length * 8 / 2;

But it works only for one Label (not the others).

So, how is it possible to know the effective size of the text (size in
pixels) ?


Any reason not to set the TextAlign property on the label to
ContentAlignment.MiddleCenter?

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Jul 21 '05 #3

"Jon Skeet [C# MVP]" <sk***@pobox.com> a écrit dans le message de
news:MP************************@msnews.microsoft.c om...
Mathieu Chavoutier <No****@NoSpam.org> wrote:

So, how is it possible to know the effective size of the text (size in
pixels) ?


Any reason not to set the TextAlign property on the label to
ContentAlignment.MiddleCenter?


Hum, yes, I did not noticed it.

Thanks.
Jul 21 '05 #4

"Jon Skeet [C# MVP]" <sk***@pobox.com> a écrit dans le message de
news:MP************************@msnews.microsoft.c om...
Mathieu Chavoutier <No****@NoSpam.org> wrote:

So, how is it possible to know the effective size of the text (size in
pixels) ?


Any reason not to set the TextAlign property on the label to
ContentAlignment.MiddleCenter?


Hum, yes, I did not noticed it.

Thanks.
Jul 21 '05 #5

"Mathieu Chavoutier" <No****@NoSpam.org> a écrit dans le message de
news:up**************@tk2msftngp13.phx.gbl...
Hum, yes, I did not noticed it.

Thanks.


Even if it seems there is no joyce inside the last message, there is one :o)
(sorry to post for nothing, but I found my last message too cold, and it was
not the goal, because I am happy to have a solution)
Jul 21 '05 #6

"Mathieu Chavoutier" <No****@NoSpam.org> a écrit dans le message de
news:up**************@tk2msftngp13.phx.gbl...
Hum, yes, I did not noticed it.

Thanks.


Even if it seems there is no joyce inside the last message, there is one :o)
(sorry to post for nothing, but I found my last message too cold, and it was
not the goal, because I am happy to have a solution)
Jul 21 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Marti | last post by:
Dear everyone, Its my understanding that IE6 now uses a default text-size of "Small" rather than IE5's "Medium". Since I have used relative font-sizes (usually in ems) on all my sites, I am...
4
by: tshad | last post by:
I am having trouble with links in my DataGrid. I have Links all over my page set to smaller and they are consistant all over the page in both Mozilla and IE, except for the DataGrid. Here is a...
8
by: Ty Moffett | last post by:
What is the best way to find the size of a folder (actually it's contents) on a disk?
7
by: Daniel Kaplan | last post by:
I have the item below at the top of my style sheet. And it seems that the font-szie is ignored. I know that my linked style sheet is being read, and used because if I remove the font-family line,...
14
by: Roger Withnell | last post by:
How to I find out what size text the browser is set to? Thanks in anticipation.
7
by: Kai-Mikael Jää-Aro | last post by:
Here is an example HTML file: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>Test!</title> </head> <body>...
0
by: benfly08 | last post by:
Hi, guys. I'm developing a web application for Sales Department people in my company. I used my 1024X768 resolution and "Medium" IE text size to test my Layout and it worked fine. However, some...
18
by: Diogenes | last post by:
Hi All; I, like others, have been frustrated with designing forms that look and flow the same in both IE and Firefox. They simply did not scale the same. I have discovered, to my chagrin,...
4
by: HeroOfSpielburg | last post by:
Hello, I'm very new to CSS and still in the reference/copy/paste/edit stage, so please forgive my ignorance. I'm using CSS for my blog, and while the font size is fine in Firefox, it is...
5
by: Stepheno | last post by:
Hi, I am a recently converted Iseries (AS/400) RPG programmer trying to learn HTML/CSS/JavsScript all at the same time (not fun). My problem deals mostly with CSS. I will be reveiving a table,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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...
0
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,...
0
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...
0
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...

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.