I know I can use System.Drawing.Printing.PrintPageEventArgs and the MeasureString() to get the width of the text based on font
I would like to do this in the form's load event, i have 3 labels that i only need the width set based on the text's width (with respect to the font, which can be different depending on the config file the app loads on startup)
how would i go about doing this?
here's what i've tried:
I would like to do this in the form's load event, i have 3 labels that i only need the width set based on the text's width (with respect to the font, which can be different depending on the config file the app loads on startup)
how would i go about doing this?
here's what i've tried:
VB.NET:
Private Sub frmMain_Load (...) Handles MyBase.Load
Dim e As New System.Drawing.Printing.PrintPageEventArgs
lblEmail1.Width = CInt(e.Graphics.MeasureString(.Email1, lblEmail1.Font).Width)
End Sub