473,386 Members | 1,698 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Resizing a richtextbox within mainform...

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
5 2415
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
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
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
* "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
* "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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: vanvee | last post by:
Hi I have a user control that contains a RichTextBox in vb.net. In my program, I create multiple instances of this control (with the RichTextBox being in each one), that appear one above the...
4
by: Thomas Richter | last post by:
Hi, I can't get of the black flicker when I resize my form. this = Mainform : System.Windows.Forms.Form If I set the size from 300 to 500 I see for ca 500ms some black areas. I try to solve it...
1
by: TheBinar | last post by:
Hi I have a user control that contains a RichTextBox in vb.net. In my program, I create multiple instances of this control (with the RichTextBox being in each one), that appear one above the...
12
by: M O J O | last post by:
Hi, If I inside a thread creates a RichTextBox and only use this inside the thread, will there be any thread problems? I need to convert between Text and RTF inside a thread. Thanks!! M...
9
by: Jacek Jurkowski | last post by:
.... make COM exposed object to have both constructors COM visible not only the first one?
0
by: Vimalathithan | last post by:
I just developing a editor. I have provide the options like Bold, Italic, underlin, font change, font size change. These font options are keep in with one toolstripbutton. the toolstripbar keep...
9
by: dli07 | last post by:
Hello, I'm trying to convert a piece of code that creates a dynamic vertical resizing bar in a table from internet explorer to firefox. It's based on a post from...
0
by: TAB | last post by:
"none" <none@none.comskrev i meddelandet news:eaJIxCA7IHA.2260@TK2MSFTNGP03.phx.gbl... Use richtextbox selection properties. Like richTextBox.SelectedText or SelectedRtf if you would like to...
0
by: Linda Liu[MSFT] | last post by:
Hi CES, Thank you for posting here! I notice that you post a same issue in the microsoft.public.dotnet.framework.windowsforms.controls newsgroup and I have replied to that thread. For your...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.