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

Finding required height of label

I'm trying to create a form similar to a VB messagebox but with custom
content. One of the things I want to be able to do is display some text in a
label at the top of the messagebox form and have the form automatically
expand to make room for it (which could be just a few words, or several
paragraphs).

In VB6 I used to use a useful trick of setting AutoSize property of the
label to True, populating the Text property, setting the Width to be the
width of my form, and then reading the Height property. VB6 would
automatically adjust the height to be whatever was required to fit all the
text in.

In VB.NET, this same procedure doesn't work. Setting the Width of an
AutoSize label no longer has any effect (the statement is ignored and the
original width stays in place).

Can anyone suggest a way that I could find the required height of the label
in order for it to completely display the supplied text in VB.NET?

Many thanks,

--

(O)enone
Nov 21 '05 #1
2 2139
Hi,

See the article at:
http://www.dotnet247.com/247referenc...43/216202.aspx

BTW, Autosize works as expected in VS 2005.
--
Mike

Mike McIntyre
Visual Basic MVP
www.getdotnetcode.com
"Oenone" <no***@nowhere.com> wrote in message
news:u4**************@TK2MSFTNGP10.phx.gbl...
I'm trying to create a form similar to a VB messagebox but with custom
content. One of the things I want to be able to do is display some text in
a label at the top of the messagebox form and have the form automatically
expand to make room for it (which could be just a few words, or several
paragraphs).

In VB6 I used to use a useful trick of setting AutoSize property of the
label to True, populating the Text property, setting the Width to be the
width of my form, and then reading the Height property. VB6 would
automatically adjust the height to be whatever was required to fit all the
text in.

In VB.NET, this same procedure doesn't work. Setting the Width of an
AutoSize label no longer has any effect (the statement is ignored and the
original width stays in place).

Can anyone suggest a way that I could find the required height of the
label in order for it to completely display the supplied text in VB.NET?

Many thanks,

--

(O)enone

Nov 21 '05 #2
Mike McIntyre [MVP] wrote:
Can anyone suggest a way that I could find the required height of the
label in order for it to completely display the supplied text in
VB.NET?
See the article at:
http://www.dotnet247.com/247referenc...43/216202.aspx
Many thanks for that -- that looks like it's exactly what I'm after.
BTW, Autosize works as expected in VS 2005.


Ah, that's good. I wondered whether it was "by design" in VS2003, it'll be
nice to get the old functionality back.

--

(O) e n o n e
Nov 21 '05 #3

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

Similar topics

3
by: Trent | last post by:
Hello, I have a <fieldset> in a <TD>. I want the fieldset to be as high as the TD. Setting the fieldset's height to 100% works in IE. Opera ignores it. Firefox & Netscape 7.1 give it the...
14
by: Oleg | last post by:
Hello there: I've been trying to create two different sets of required fields in one form and to use a radiobutton as sort of a switcher between these sets. In my HTML form there are two...
2
by: TadPole | last post by:
Hi all, My main problems are::::::::: 1. Set a value within a block container that can be used and changed by subsequent templates/block-containers/tables etc.. 2. get/determine/find the...
1
by: Doug | last post by:
The html below shows DataList "DiscountList" nested within DataList "EventItemList". DiscountList contains a Label control. I'm trying to find the label, using FindControl, during...
4
by: m | last post by:
Hello I need to find out full URL of my application name, I tried using Request.ServerVariables but it returns only serverername, and I need virtual directory name as well. Thnx in advance
3
by: Paul W | last post by:
I have a ListBox Webcontrol with an OnSelectedIndexChanged event (and AutoPostBack=true). If I disable EnableViewState for this control, when I change the listbox index, the form does a postback...
1
by: spidur1 | last post by:
For some reason these fields are not being validated before the postback. Here the HTML page. Am I missing something from the validator controls that needs to be set? <table cellpadding="0"...
1
by: Nate12o6 | last post by:
Hey guys, i am having trouble with getting the heights corrected on my fieldset. Right now i have 2 table cells side by side. And inside of each there is a field set. The fieldset to the right...
2
by: ssmeshack | last post by:
Hai all, Im having problem to set minimum height to <td> tag. It only takes height only not min-height. Im ie7 browser and developing web based system in Visual Web Deveploper 2008 (C# .Net). ...
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: 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:
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: 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...

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.