Reputation: 15
How do i dynamically resize the text in a RichTextbox so that it fills up the entire rich textbox? any help is much appreciated. thank you.
Upvotes: 0
Views: 1230
Reputation: 870
I think you might have to get creative with the 'Font' constructor. For example, on a click event then construct a new Font using some relationship with your application (or textbox size) with the desired font size.
Protected Sub btn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btn.Click
Dim yourfontsize As Integer
'machinery to create desired font size
If blah then
yourfontsize = X()
Else
yourfontsize = Y()
End If
yourtextbox.SelectionFont = New Font("Tahoma", yourfontsize, FontStyle.Bold)
End Sub
Where X() and Y() are functions to return your target font sizes based on whatever else may be going on within your application.
Reference: http://msdn.microsoft.com/en-us/library/yh8963yx.aspx
Hope that helps!
-sf
Upvotes: 0
Reputation: 4866
This MSDN article almost answers your question. http://msdn.microsoft.com/en-us/library/bb986765.aspx. You may download the attached sample there.
Upvotes: 1