473,396 Members | 1,990 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,396 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 7968
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
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
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...
0
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,...

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.