Finding required height of label

O

Oenone

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,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top