By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,716 Members | 1,296 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,716 IT Pros & Developers. It's quick & easy.

Resizing a richtextbox within mainform...

P: n/a
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?

Nov 20 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
strange it seems to work for me, i did use me.width, me.height maybe thats
the catch?

"Gary" <sp**@spam.com> wrote in message
news:%2***************@TK2MSFTNGP11.phx.gbl...
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?

Nov 20 '05 #2

P: n/a
Cor
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
Nov 20 '05 #3

P: n/a
rtfTextArea.Height = Me.Height - 80

rtfTextArea.Width = Me.Width - 20

this worked

thanks guys...

Gary

"Gary" <sp**@spam.com> wrote in message
news:%2***************@TK2MSFTNGP11.phx.gbl...
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?

Nov 20 '05 #4

P: n/a
* "Gary" <sp**@spam.com> scripsit:
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.

--
Herfried K. Wagner
MVP VB Classic, VB.NET
<http://www.mvps.org/dotnet>
Nov 20 '05 #5

P: n/a
* "Gary" <sp**@spam.com> scripsit:
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
///

--
Herfried K. Wagner
MVP VB Classic, VB.NET
<http://www.mvps.org/dotnet>
Nov 20 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.