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

Width of Label

Hi,
An easy on I'm guessing!
How do I restrict the length of a label? I have tried setting the width

to say 200px but if the user inputs a continuous line of characters
it's doesn't wrap.
Thanks in advance.
Jack

Nov 19 '05 #1
1 1449
The problem you have is not the width attribute of the label control rather
it is the continuous line of characters. You will have to reformat any
string that is longer than the maximum length of your label. Here is an
example of a function that you pass the string that you wish to space out
and the max length of the label that you wish to display:

Private Function SpaceOut(ByVal inputstring As String, ByVal len As Integer)
As String
If inputstring.Length > len Then
Return inputstring.Substring(0, len) & " " &
SpaceOut(inputstring.Substring(len + 1), len)
Else
Return inputstring
End If
End Function

So if you have a text in a variable called LongLine that want to display in
a label named lblText, you would use it like this:
lblText.Text = SpaceOut(LongLine, 30)

---
http://www.societopia.net
http://www.webswapp.com
"jack-e" <ja****@humlog.com> wrote in message
news:11*********************@f14g2000cwb.googlegro ups.com...
Hi,
An easy on I'm guessing!
How do I restrict the length of a label? I have tried setting the width

to say 200px but if the user inputs a continuous line of characters
it's doesn't wrap.
Thanks in advance.
Jack

Nov 19 '05 #2

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

Similar topics

2
by: Alex Shi | last post by:
In php, is there a way obtain the width of a charactor of a certain font? Alex -- ================================================== Cell Phone Batteries at 30-50%+ off retail prices!...
3
by: Andre | last post by:
Hi, Did someone know why this code does'nt work (The TableCell Width). The cell don't have 600 and 150 like writed in width="600" and width="150". <asp:datagrid id="DataGrid1" ...
2
by: Charleees | last post by:
Hi all, I have a DataGrid with Template Columns..... There are LAbels,Linkbuttons in the Single Row.. I have to set the Constant Column width for those Template Columns in Grid... Wat...
1
by: Patrick Lioi | last post by:
Label label = new Label(); label.Width = 1; label.AutoSize = true; label.Text = "A long string, requiring a width larger than 1."; //At this point, Width is still 1. What am I missing? ...
5
by: BobLaughland | last post by:
Hi There, I am trying to get some fields to align on a web page, like this, To: From: Subject: Each of the fields above have a corresponding asp:Textbox control next to it that I cannot...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...
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...

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.