Resizing a richtextbox within mainform...

  • Thread starter Thread starter Gary
  • Start date Start date
G

Gary

hi...

how do I successfully resize a richtextbox within the main form, my code as
follows...

Private Sub frmMainForm_Resize(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Resize

rtfTextArea.Height = frmMainForm.ActiveForm.Height - 10

rtfTextArea.Width = frmMainForm.ActiveForm.Width - 100

End Sub

as expected I get a 'System.NullReferenceException' error, how do I fix this

Thanks,

Gary

p.s. it so much easier in VB6?
 
Hi Gary,
Did you look to the dock properties, that makes all so much easier than in
VB6
(Maybe you have to use some extra pannels, but when i see that you use
almost the whole form I think not)

I hope this helps a little bit?
Cor
 
rtfTextArea.Height = Me.Height - 80

rtfTextArea.Width = Me.Width - 20

this worked

thanks guys...

Gary
 
* "Gary said:
rtfTextArea.Height = Me.Height - 80

rtfTextArea.Width = Me.Width - 20

This will cause incorrect display results if borders and taskbars of the
form have an other size. You may want to use the value of the
'ClientSize' property.
 
* "Gary said:
how do I successfully resize a richtextbox within the main form, my code as
follows...

Private Sub frmMainForm_Resize(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Resize

rtfTextArea.Height = frmMainForm.ActiveForm.Height - 10

rtfTextArea.Width = frmMainForm.ActiveForm.Width - 100

The exception will be thrown if, for example, there is no 'ActiveForm'
because no forms are displayed. You can check this with code like that:

\\\
If Not Me.ActiveForm Is Nothing Then
...
End If
///
 
correct me if i'm wrong ;p
so me.height gives the outside of the form and clientsize.height gives the
inside? like the scaleheight in vb6 ?

i haven't used these thing in .NET tnx to the anchors but its always usefull
to know ;)

eric
 
* "EricJ said:
correct me if i'm wrong ;p
so me.height gives the outside of the form and clientsize.height gives the
inside? like the scaleheight in vb6 ?

Yes.
 
Back
Top