Reputation: 27
I want to resize a rich text box to fit the character inside it without scrolling on it....i removed the scroll bar property of the rich text box and added some code on the contents resized event of the rich text box:
Private Sub TextBox_ContentsResized(sender As Object, e As ContentsResizedEventArgs) Handles TextBox.ContentsResized
If TextBox.Height < e.NewRectangle.Height + 12 Then
TextBox.Height = e.NewRectangle.Height + 12
End If
End Sub
the rich text box can now resize it's height...the problem is I can't find a way to make it shrink as the user delete some lines from the rich text box
Upvotes: 0
Views: 4143
Reputation: 2477
You don't have to make an if condition. Just do this...
Private Sub TextBox_ContentsResized(sender As Object, e As ContentsResizedEventArgs) Handles TextBox.ContentsResized
TextBox.Height = e.NewRectangle.Height + 12
End Sub
Upvotes: 2