473,395 Members | 1,466 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.

fitting label dimensions to length of string

I have a method that is returning a string which can be of any length.
Once this string is returned I want to display it on screen in a label
control. How can I make the label control's height and width be
flexible so that it always fits the length of the string it contains?

<asp:Label ID="lblSQL" runat="server" Height="600" Width="600"
BackColor="blue" ForeColor="white" Font-Names="Verdana"
Font-Size="Small"></asp:Label>

protected void Page_Load(object sender, EventArgs e)
{
ViewState["CountGUID"] = Request.QueryString["GUID"];

string strCountSQL =
GetCountSql(ViewState["CountGUID"].ToString());

lblSQL.Text = strCountSQL;
}


*** Sent via Developersdex http://www.developersdex.com ***
Nov 14 '08 #1
1 1936
Just suppress the heigh and width attributes. An HTML document is rendered
so that each element are sized to fit their content....

"Mike P" <mi*******@gmail.coma écrit dans le message de groupe de
discussion : uP**************@TK2MSFTNGP03.phx.gbl...
I have a method that is returning a string which can be of any length.
Once this string is returned I want to display it on screen in a label
control. How can I make the label control's height and width be
flexible so that it always fits the length of the string it contains?

<asp:Label ID="lblSQL" runat="server" Height="600" Width="600"
BackColor="blue" ForeColor="white" Font-Names="Verdana"
Font-Size="Small"></asp:Label>

protected void Page_Load(object sender, EventArgs e)
{
ViewState["CountGUID"] = Request.QueryString["GUID"];

string strCountSQL =
GetCountSql(ViewState["CountGUID"].ToString());

lblSQL.Text = strCountSQL;
}


*** Sent via Developersdex http://www.developersdex.com ***

Nov 14 '08 #2

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

Similar topics

2
by: Roggey | last post by:
Hello I'm using System.Windows.Forms.Label and I want to add some text, where one or more words are bold or italic. I tried it with html tags but does not work. Somewhere i did read it should...
1
by: jack-e | last post by:
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...
1
by: ngreplies | last post by:
I am using a label as a tooltip box because I need to be able to change the background of the box depending on the information it is representing. That aside, I need to be able to auto-size the...
3
by: Robert W. | last post by:
Long ago I developed a simple algorithm for calculating how much space is required to display a multi-line label in a limited width. It seemed to be working okay but then my testing revealed a...
0
by: Anish G | last post by:
Hi, I am trying to dispaly multiple label images in to a browser using response.binarywrite(). But the images are getting over written.I am attaching the code with this, Please help me out to...
2
by: Miles | last post by:
Hi all, Wondering if anyone can help me. If i have an associative array: $arr = array( "one" =array(1, 2, 3), "two" =array(5, 6), "three" =array(7,8,9,10) .... "n" =array(p,q,r....)
2
by: Adam Teale | last post by:
hey guys Is there a builtin/standard install method in python for retrieving or finding out an image's dimensions? A quick google found me this:...
11
by: Peter Larsen [] | last post by:
Hi, I have two questions related to the Label control. How do i prevent the label from expand the canvas into 2 lines (word wrap) ?? At the moment i set AutoSize to false (to prevent the word...
2
by: Mike P | last post by:
I have a method that is returning a string which can be of any length. Once this string is returned I want to display it on screen in a label control. How can I make the label control's height and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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?
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
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
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.