Count Line in Multiline Label Control


My New Task

Count Total Number Lines in Label Control.

Function LineCount(ByVal Label As Label) As Integer  

Dim g As Graphics = Label.CreateGraphics    
Dim LineHeight As Single = g.MeasureString("X", Label.Font).Height))  
Dim TotalHeight As Single = g.MeasureString(Label.Text, Label.Font, Label.Width).Height    

Return CInt(Math.Round(TotalHeight / LineHeight))
End Function

Comments

Popular posts from this blog

Shared / Static Class in vb.net/C#

Xamarin Forms : PopUp Page with RG.Plugins.Popup

Text was truncated or one or more characters had no match in the target code page.". (SQL Server Import and Export Wizard)