D
**Developer**
I don't believe the code below gives the correct string size in inches.
Can any one tell me what is wrong?
I need to know the size of the string before I add it to the RichTextBox
Thanks
Public ReadOnly Property TxtMeasureString(ByVal str As String) As SizeF
Get
Dim Gr As Graphics = Me.CreateGraphics
Dim MeasureString As SizeF = Gr.MeasureString(str,
ControlRichTextBox1.SelectionFont())
TxtMeasureString = New SizeF(MeasureString.Width / Gr.DpiX,
MeasureString.Height / Gr.DpiY)
Gr.Dispose()
End Get
End Property
Can any one tell me what is wrong?
I need to know the size of the string before I add it to the RichTextBox
Thanks
Public ReadOnly Property TxtMeasureString(ByVal str As String) As SizeF
Get
Dim Gr As Graphics = Me.CreateGraphics
Dim MeasureString As SizeF = Gr.MeasureString(str,
ControlRichTextBox1.SelectionFont())
TxtMeasureString = New SizeF(MeasureString.Width / Gr.DpiX,
MeasureString.Height / Gr.DpiY)
Gr.Dispose()
End Get
End Property