473,809 Members | 2,931 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to prevent Label text from wrapping?

abc
This seems like a stupid question, but I can't find the property to prevent
the text in a Label control from wrapping on the next line. Thanks.
Nov 15 '05 #1
4 10416
Try with setting 'AutoSize' property to true.

Thanks,
VijayaKrishna P.
"abc" <ab*@xyz.com> wrote in message
news:#B******** ******@TK2MSFTN GP09.phx.gbl...
This seems like a stupid question, but I can't find the property to prevent the text in a Label control from wrapping on the next line. Thanks.

Nov 15 '05 #2
Hi,

Make the height of the label lower, just the height of a line, in this case
you will not see the rest of the text. or use AutoSize as pondala suggested.
Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"abc" <ab*@xyz.com> wrote in message
news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
This seems like a stupid question, but I can't find the property to prevent the text in a Label control from wrapping on the next line. Thanks.

Nov 15 '05 #3

Hi,

Thanks for posting in this group.
If you want to adjust your label to fit all your text to display, the
simplest way is autosize property.
If you want to fix the label's length and cut the wapped text of label
control, you should use Graphics.Measur eString to determine the string's
length.
Sample code like this:

private void button1_Click(o bject sender, System.EventArg s e)
{
Graphics g=this.CreateGr aphics();
Font f=label1.Font;
string labelstr=label1 .Text;
char [] char_arr=labels tr.ToCharArray( );
int width;
int count=0;
for(int i=0;i<char_arr. Length;i++)
{
width=(int)(g.M easureString(la belstr.Substrin g(0,i+1),f).Wid th);
if(width>=label 1.Width)
{
count=i;
break;
}
}
label1.Text=lab elstr.Substring (0,count);
}

It works well on my machine.
Hope this helps,

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 15 '05 #4

Hi,

Does our posts make sense to you?
If you still have any concern, please feel free to tell me.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 15 '05 #5

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

Similar topics

2
2558
by: John Baro | last post by:
If I have a label (AutoSize = false) with more text than can fit it wraps downwards. I need to determine how high the label needs to be to fit the whole of the text in. I can then put it into a scrolling panel and scroll it like a textbox. Any ideas on how to do this or a more appropriate method are muchly appreciated. Cheers JB
4
21767
by: Richard MSL | last post by:
I have an application using WinForms under C#. I do not use the IDE, I use the command line compiler, I build my controls in my application code. The application generally works fine, except for one small problem: I have made a user control that has a Label Box to display the prompt. The problem is that the text in the label box sometimes wraps to a second line on a word break, and I do not want it to. I have tried all the wrapping type...
5
9624
by: le_mo_mo | last post by:
Hi, I am trying to have one label on a form with multi line display of the results from a database query. so my query looks like Select FirstName+" "+LastName+"\r\n"+Address as Info I want to have the label show FirstName LastName
7
2936
by: Mike Casey | last post by:
Hello all, I have ASP.NET label controls tied to a datasource (so text will vary in length depending on the record). In IE everything looks great--text is wrapped if needed. In Netscape and Opera, the text extends horizontally and does not wrap. Any ideas would be most appreciated! Thanks,
1
1768
by: mg | last post by:
I set the width of a WebForm Label but do not get line wrapping (see below). What can I do to get line wrapping WebForm1.asp <asp:Labe id="Label1" style="Z-INDEX: 101; LEFT: 40px; POSITION: absolute; TOP: 48px runat="server" Width="150px" Height="64px"></asp:Label
2
1434
by: David | last post by:
Hello. I have a Label control on my web form and I have long text in it. What I want is to disable text wrapping of this Label. Is it possible? Also I want to know how can I set text alignment to right in Label? Thank you.
7
19553
by: Joe | last post by:
I have a label control that will be filled with text at runtime. The length of the text will vary, but the label must stay the same size. Is there a way to set the font size of the text such that it completely fills the label? For example, if the text is "Santa Claus" the font size might have to be 130 points to fill up a 637x476 label, where if the text is "Once upon a midnight dreary / while I pondered weak and weary / over many a...
14
2362
by: Ed Jay | last post by:
On a multi-textbox form, linked to an external js, I use onBlur to call: function chkNum(cellname) { var str = document.getElementById(cellname).value.toString(10); if (str < 28 || str > 36) {alert("Temperature entered is out of range."); return;} } I enter data into the first textbox and move the cursor to the second textbox. The function is properly called. Since textbox2 is empty, when I
4
5603
by: Mudcat | last post by:
I've tried quite a few things to get this correct but have hit a couple of sticking points that I can't figure out. I need to ge the Text box to function like the 'wraplength' option in a Label. I've been able to adjust the height of the text by calculating the number of lines needed to display the text. That's fairly simple. I know the number of characters in the text and width of the box (which is static). From that point I can...
0
9721
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
10633
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
10376
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...
1
10375
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
9198
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...
0
6880
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
5686
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3860
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3011
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.