We have created an Application called MyNotes with a rich text box, a menu with standard items, and a toolstrip.
We are going to write code so that the richtext box fills the lower part of the form. We want to do this at form load and also whenever the form is resized. We will create a general sub and call it from both form load and form resize:
- Continue with the MyNotes Application.
- Drag the RichTextBox1 so that it is just under the toolstrip and at the left of the form.
- Write the code as shown below:
Public Class Form1
Private Sub Form1_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Resize
ResizeRichText()
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ResizeRichText()
End Sub
Private Sub ResizeRichText()
RichTextBox1.Width = Me.Width
RichTextBox1.Height = Me.Height - RichTextBox1.Location.Y
End Sub
End Class
- Click Save All
at this point and run the program to see what we have so far.