469,610 Members | 1,844 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,610 developers. It's quick & easy.

Programatically getting a RichTextBox to scroll - What Am I doing Wrong

Ive been working on this since yesterday and its bugging me. Although the
event is firing, The box does not scroll. Can anyone see what Im doing
wrong. I suspect it is stupidly simple.

TIA

SubClass RichtextBox in order to fire the OnVScroll Event

Public Class MyRichTextBox

Inherits RichTextBox

Public Sub PerformVScroll()

MyBase.OnVScroll(EventArgs.Empty)

End Sub

End Class

- This button invokes the PerformVScroll -

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles PerformVscroll.Click

RTB.PerformVScroll()

End Sub

- THis confirms that the event has been raised -

Private Sub handleScroll(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles RTB.VScroll

Console.WriteLine("Handling scroll")

End Sub


--
Regards - One Handed Man

Author : Fish .NET & Keep .NET
=========================================
This posting is provided "AS IS" with no warranties,
and confers no rights.

Nov 20 '05 #1
4 4155
In article <uP**************@TK2MSFTNGP12.phx.gbl>, terry_burnsREMOVE%
FO*********@BTOpenworld.com says...
Ive been working on this since yesterday and its bugging me. Although the
event is firing, The box does not scroll. Can anyone see what Im doing
wrong. I suspect it is stupidly simple.

TIA

SubClass RichtextBox in order to fire the OnVScroll Event

Public Class MyRichTextBox

Inherits RichTextBox

Public Sub PerformVScroll()

MyBase.OnVScroll(EventArgs.Empty)

End Sub

End Class

- This button invokes the PerformVScroll -

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles PerformVscroll.Click

RTB.PerformVScroll()

End Sub

- THis confirms that the event has been raised -

Private Sub handleScroll(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles RTB.VScroll

Console.WriteLine("Handling scroll")

End Sub


You're simply causing all event subscribers to be notified that a scroll
has happened. It's not actually performing the scroll. For that, you
would probably either need to:

1) Send the WM_VSCROLL message to your control.
2) or try the ScrollToCaret() function.

--
Patrick Steele
Microsoft .NET MVP
http://weblogs.asp.net/psteele
Nov 20 '05 #2
The carret worked ok so thanks for that. I looked for examples on how to
send messages to the control but of yet have not found any. Do you have a
good reference I can look at ?

Many Thanks

--
Regards - One Handed Man

Author : Fish .NET & Keep .NET
=========================================
This posting is provided "AS IS" with no warranties,
and confers no rights.
"Patrick Steele [MVP]" <pa*****@mvps.org> wrote in message
news:MP************************@msnews.microsoft.c om...
In article <uP**************@TK2MSFTNGP12.phx.gbl>, terry_burnsREMOVE%
FO*********@BTOpenworld.com says...
Ive been working on this since yesterday and its bugging me. Although the event is firing, The box does not scroll. Can anyone see what Im doing
wrong. I suspect it is stupidly simple.

TIA

SubClass RichtextBox in order to fire the OnVScroll Event

Public Class MyRichTextBox

Inherits RichTextBox

Public Sub PerformVScroll()

MyBase.OnVScroll(EventArgs.Empty)

End Sub

End Class

- This button invokes the PerformVScroll -

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles PerformVscroll.Click

RTB.PerformVScroll()

End Sub

- THis confirms that the event has been raised -

Private Sub handleScroll(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles RTB.VScroll

Console.WriteLine("Handling scroll")

End Sub


You're simply causing all event subscribers to be notified that a scroll
has happened. It's not actually performing the scroll. For that, you
would probably either need to:

1) Send the WM_VSCROLL message to your control.
2) or try the ScrollToCaret() function.

--
Patrick Steele
Microsoft .NET MVP
http://weblogs.asp.net/psteele

Nov 20 '05 #3
In article <Ot**************@TK2MSFTNGP11.phx.gbl>, terry_burnsREMOVE%
FO*********@BTOpenworld.com says...
The carret worked ok so thanks for that. I looked for examples on how to
send messages to the control but of yet have not found any. Do you have a
good reference I can look at ?


See this google post:

http://tinyurl.com/m4in

--
Patrick Steele
Microsoft .NET MVP
http://weblogs.asp.net/psteele
Nov 20 '05 #4
Excellent Patrick, You have been most helpful this did the trick

;-D

--
Regards - One Handed Man

Author : Fish .NET & Keep .NET
=========================================
This posting is provided "AS IS" with no warranties,
and confers no rights.
"Patrick Steele [MVP]" <pa*****@mvps.org> wrote in message
news:MP************************@msnews.microsoft.c om...
In article <Ot**************@TK2MSFTNGP11.phx.gbl>, terry_burnsREMOVE%
FO*********@BTOpenworld.com says...
The carret worked ok so thanks for that. I looked for examples on how to
send messages to the control but of yet have not found any. Do you have a good reference I can look at ?


See this google post:

http://tinyurl.com/m4in

--
Patrick Steele
Microsoft .NET MVP
http://weblogs.asp.net/psteele

Nov 20 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Rachel Suddeth | last post: by
7 posts views Thread by Richard | last post: by
1 post views Thread by Daniel Friend | last post: by
1 post views Thread by dotnetnoob | last post: by
2 posts views Thread by =?Utf-8?B?SmVzcGVyLCBEZW5tYXJr?= | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.