form height?
Posted: Sat Mar 17, 2018 10:47 am
hello,
i like to resize the form just to display the label1 text to adjust the size to display
so the default form height = 254
so we like to get the form height just high enough to display the text inside the label1
if more text in label1 to higher the form will be
the less text in label1 the smaller the form will be
i like to resize the form just to display the label1 text to adjust the size to display
so the default form height = 254
so we like to get the form height just high enough to display the text inside the label1
if more text in label1 to higher the form will be
the less text in label1 the smaller the form will be
Code: Select all
Thanks Dim w As Integer = label1.Width
Dim h As Integer = CalculateHeight()
Me.Height = h / 2 - label1.Text.Length
Private Function CalculateHeight() As Single
Dim g As Graphics = label1.CreateGraphics
Return g.MeasureString(label1.Text, label1.Font).Width
End Function