How to Get the value of scrollbar

  • Thread starter Ahmad Jalil Qarshi
  • Start date
A

Ahmad Jalil Qarshi

Hi!



I am making an application and need to capture the event when RichTexBox
control's vertical scrollbar's values changes. There is an event named
VScroll but it is fired when mouse is first time clicked on scroll bar. I
need the event when the value of scroll bar changes like when we drag the
bullet on the scroll bar or when we manually press the down/Up arrow
button when the textbox is in focus and text is scrolled up or down.

How can I get the value of scrollbar when the event is fired?



It doesn't fire when the bar is pulled....





Any help will be highly appreciated



Thanks in advance



Ahmad Jalil qarshi
 
M

Matt

Ahmad said:
Hi!



I am making an application and need to capture the event when RichTexBox
control's vertical scrollbar's values changes. There is an event named
VScroll but it is fired when mouse is first time clicked on scroll bar. I
need the event when the value of scroll bar changes like when we drag the
bullet on the scroll bar or when we manually press the down/Up arrow
button when the textbox is in focus and text is scrolled up or down.

How can I get the value of scrollbar when the event is fired?

Odds are, you can't, at least not with a standard RichTextBox. C#
doesn't
allow for every single event to be captured, just the ones that
programmer
originally thought about.

All is not lost, however. To do this, just derive your own class from
RichTextBox,
override the window procedure, capture the messages you want (in your
case,
WM_VSCROLL with its various parameters set) and create your own events
for it. It really isn't very hard to do, you can find fairly good
examples on
codeproject.com, for example.

Although this particular example is for a listbox, you should be able
to see the
technique involved:
http://www.codeproject.com/cs/combobox/ScrollingListbox.asp

Matt
 
A

Ahmad Jalil Qarshi

Thanks Matt


Matt said:
Odds are, you can't, at least not with a standard RichTextBox. C#
doesn't
allow for every single event to be captured, just the ones that
programmer
originally thought about.

All is not lost, however. To do this, just derive your own class from
RichTextBox,
override the window procedure, capture the messages you want (in your
case,
WM_VSCROLL with its various parameters set) and create your own events
for it. It really isn't very hard to do, you can find fairly good
examples on
codeproject.com, for example.

Although this particular example is for a listbox, you should be able
to see the
technique involved:
http://www.codeproject.com/cs/combobox/ScrollingListbox.asp

Matt
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top