Hi Herfried
You read my mind ... or I read yours :-)
After posting, I got on and created a user control called AutoLabel,
inherited from Label, and included the self same code in the OnResize
method, et. al. I reckoned that it would be as effective as the original,
and it was.
Cheers.
Charles
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:eH****************@TK2MSFTNGP10.phx.gbl...
"Charles Law" <bl***@nowhere.com> schrieb:I have noticed that the label control in .NET doesn't work quite the same
as it used to do.
It used to be possible to set it to auto-size in such a way that the
width remained constant and the height varied according to the amount of
text in the control.
Have I missed a setting somewhere or is there another way of doing it
now?
\\\
Me.Label1.Text = "Hello Bla World Foo Goo Bloo Hoo Joo..."
Dim g As Graphics = Me.Label1.CreateGraphics()
Me.Label1.Height = _
CInt( _
g.MeasureString( _
Me.Label1.Text, _
Me.Label1.Font, _
Me.Label1.Width _
).Height _
)
g.Dispose()
///
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>