473,388 Members | 1,207 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,388 software developers and data experts.

How to justify text in a label control?

I want to justify the text in a label control so that all of the text fills
the label equally, but there don't seem to be any properties to set to allow
this.

Can anyone help?
Nov 21 '05 #1
4 5135
Hi,

What you want is an algorithm that takes into consideration the width of the
label control, the number of characters and the font size. In addition, you
may have to distinguish between caps and lower case, as these will differ
even if the font size is the same; also, spaces and other elements of
punctuation will have to be considered, as will the font face, as these too
can differ even if the point size is the same. You might even have to
consider kerning (the adjustment of space between pairs of letters to make
them more visually appealing). Finally, if the font size that is determined
by the algorithm is large enough, you might be forced to increase the height
of the label control to accommodate each character.

And that is why there is no function for it - it's very complicated, but I
would imagine doable.

HTH,

Bernie Yaeger

"cashdeskmac" <ca*********@discussions.microsoft.com> wrote in message
news:EF**********************************@microsof t.com...
I want to justify the text in a label control so that all of the text fills
the label equally, but there don't seem to be any properties to set to
allow
this.

Can anyone help?

Nov 21 '05 #2
You should be able to get an acceptable solution using the Graphics Object
and Measure String by adding a space after each word then measuring the
string until it exceeds the label width then back out the last space. Of
course, you can add Kerning, etc. to improve this.
--
Dennis in Houston
"Bernie Yaeger" wrote:
Hi,

What you want is an algorithm that takes into consideration the width of the
label control, the number of characters and the font size. In addition, you
may have to distinguish between caps and lower case, as these will differ
even if the font size is the same; also, spaces and other elements of
punctuation will have to be considered, as will the font face, as these too
can differ even if the point size is the same. You might even have to
consider kerning (the adjustment of space between pairs of letters to make
them more visually appealing). Finally, if the font size that is determined
by the algorithm is large enough, you might be forced to increase the height
of the label control to accommodate each character.

And that is why there is no function for it - it's very complicated, but I
would imagine doable.

HTH,

Bernie Yaeger

"cashdeskmac" <ca*********@discussions.microsoft.com> wrote in message
news:EF**********************************@microsof t.com...
I want to justify the text in a label control so that all of the text fills
the label equally, but there don't seem to be any properties to set to
allow
this.

Can anyone help?


Nov 21 '05 #3
Thanks for the suggestions, guys, but I went with another control in the
end.Time was of the essence.

"Dennis" wrote:
You should be able to get an acceptable solution using the Graphics Object
and Measure String by adding a space after each word then measuring the
string until it exceeds the label width then back out the last space. Of
course, you can add Kerning, etc. to improve this.
--
Dennis in Houston
"Bernie Yaeger" wrote:
Hi,

What you want is an algorithm that takes into consideration the width of the
label control, the number of characters and the font size. In addition, you
may have to distinguish between caps and lower case, as these will differ
even if the font size is the same; also, spaces and other elements of
punctuation will have to be considered, as will the font face, as these too
can differ even if the point size is the same. You might even have to
consider kerning (the adjustment of space between pairs of letters to make
them more visually appealing). Finally, if the font size that is determined
by the algorithm is large enough, you might be forced to increase the height
of the label control to accommodate each character.

And that is why there is no function for it - it's very complicated, but I
would imagine doable.

HTH,

Bernie Yaeger

"cashdeskmac" <ca*********@discussions.microsoft.com> wrote in message
news:EF**********************************@microsof t.com...
I want to justify the text in a label control so that all of the text fills
the label equally, but there don't seem to be any properties to set to
allow
this.

Can anyone help?


Nov 21 '05 #4
What control did you use?
--
Dennis in Houston
"cashdeskmac" wrote:
Thanks for the suggestions, guys, but I went with another control in the
end.Time was of the essence.

"Dennis" wrote:
You should be able to get an acceptable solution using the Graphics Object
and Measure String by adding a space after each word then measuring the
string until it exceeds the label width then back out the last space. Of
course, you can add Kerning, etc. to improve this.
--
Dennis in Houston
"Bernie Yaeger" wrote:
Hi,

What you want is an algorithm that takes into consideration the width of the
label control, the number of characters and the font size. In addition, you
may have to distinguish between caps and lower case, as these will differ
even if the font size is the same; also, spaces and other elements of
punctuation will have to be considered, as will the font face, as these too
can differ even if the point size is the same. You might even have to
consider kerning (the adjustment of space between pairs of letters to make
them more visually appealing). Finally, if the font size that is determined
by the algorithm is large enough, you might be forced to increase the height
of the label control to accommodate each character.

And that is why there is no function for it - it's very complicated, but I
would imagine doable.

HTH,

Bernie Yaeger

"cashdeskmac" <ca*********@discussions.microsoft.com> wrote in message
news:EF**********************************@microsof t.com...
>I want to justify the text in a label control so that all of the text fills
> the label equally, but there don't seem to be any properties to set to
> allow
> this.
>
> Can anyone help?

Nov 21 '05 #5

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

Similar topics

0
by: Abhijeet Kumar | last post by:
Hi How can i justify align text on Label Control. I am working in C# Desktop application
4
by: Rui Patinha | last post by:
Hello, I have a label in a report that is filled up with text from a query. The problem is that I need to justify the alignment, but not as it does by default... let me try to clear this... ...
2
by: Mariame | last post by:
Hello Everyone Is there is anyway i can justify a label static content???????? Thx in Advance
5
by: tranky | last post by:
Hi... ....i've a problem. I want to justify a label text, it is possible? I want to align text to the right but also to the left. There's a way to do it? Do you know any function? Thank you for...
12
by: vbnewbie | last post by:
I am having problems accessing properties of dynamically generated objects in VB2005. Can someone please help? In a nutshell: My app creates an equal number of checkboxes and labels that share the...
5
by: tshad | last post by:
I have a datagrid that I cannot get to right justify a money amount (which is just a label). No matter what I do - it still right justifies it. <asp:TemplateColumn Visible="true"...
4
by: jayasabari | last post by:
Hi all, i am working on asp.net. i am using label to display some text in multi line. In css i am giving "text-align: justify;". It is working in IE perfectly but in Mozilla not working. ...
1
by: Dude | last post by:
Hi All, I am fairly new to Python programming. I am working on a small Tkinter project and I think I am missing something, maybe you can help. The two lines below is all I have related to the...
2
by: yuleball | last post by:
I want to properly "JUSTIFY" the text in rich textbox control. Which I mean to say is Right characters to be aligned to right margin and left characters to be aligned to left margin. An example is...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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:
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
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:
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
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.