Placing two labels exactly after eachother

  • Thread starter Thread starter Christer Bermar
  • Start date Start date
C

Christer Bermar

Hello,

I was wondering how to oder two labels in a ASP.NET web form exactly after
eachother by settings its LEFT and WIDTH propertys. Depending on the font
used and length of the string, this is dynamic. Is there an exact way to
calculate how many pixels a label is?

Regards,
Christer Bermar
 
Yes i understand that it is the width property, but it is what to put there
that is what im looking for. If a user inputs "label1" in the left label
with a font "Arial" it will be x pixels long. This is what i want to
calculate so i can position the right label after the left label.

How does one calculate the number of pixels a string/label consumes? If i
can get the number of pixels a label is long, i can just position the other
label with label.Width=Unit.Pixel(x);

Regards,
Christer Bermar
 
Christer,

Untested to get the lenght of the string text of the time now
\\\
Dim textSize As SizeF =
Graphics.FromHwnd(Me.Handle).MeasureString(Now.ToString, Me.Font)
///
I hope this helps?

Cor
 
Back
Top