Getting two scrollbars to mirror eachother

G

Guest

I have two large text boxes side by side which when loaded with text will
usually get a horizontal scrollbar automatically.

I would like to set it up so that when I scroll a bit to one direction on
one textbox, the other textbox scrolls in the same direction with the same
amount...

how to do this?
 
G

Guest

Update, I had to change from TextBox to ListView now for column support, but
I still have the same problem- how can I get two ListView's scrollbars to
mirror eachother?

There aren't even any properties/methods on ListView to get at the
scrollbars...
 
N

Nicholas Paldino [.NET/C# MVP]

MrNobody,

Basically, when you scroll one list view, you can send the LVM_SCROLL
message to the other to make that one scroll as well. You can detect when
one list view scrolls by overriding the WndProc method and looking for the
WM_VSCROLL (vertical scroll) message, I believe.

Hope this helps.
 
G

Guest

Thanks for your reply!

Ok I know how to extend the control and override the WndProc method but how
do I compare the Msg property to 'WM_VSCROLL' ? When I do:

if (m.Msg == WM_VSCROLL)

I get a compiler error, it does not know what WM_VSCROLL is...

also, onced I capture this how do I send this as a command to the other
ListView's scrollbar?


Thanks!

Nicholas Paldino said:
MrNobody,

Basically, when you scroll one list view, you can send the LVM_SCROLL
message to the other to make that one scroll as well. You can detect when
one list view scrolls by overriding the WndProc method and looking for the
WM_VSCROLL (vertical scroll) message, I believe.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

MrNobody said:
I have two large text boxes side by side which when loaded with text will
usually get a horizontal scrollbar automatically.

I would like to set it up so that when I scroll a bit to one direction on
one textbox, the other textbox scrolls in the same direction with the same
amount...

how to do this?
 
N

Nicholas Paldino [.NET/C# MVP]

MrNobody,

You can get the value for WM_VSCROLL from the C++ header file WinUser.h
(it should have been installed if you installed Visual C++, or you can
google it).

As for sending the message to the other listview, you can declare the
SendMessage function to be called through the P/Invoke layer (you can get
the definition from http://www.pinvoke.net).


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

MrNobody said:
Thanks for your reply!

Ok I know how to extend the control and override the WndProc method but
how
do I compare the Msg property to 'WM_VSCROLL' ? When I do:

if (m.Msg == WM_VSCROLL)

I get a compiler error, it does not know what WM_VSCROLL is...

also, onced I capture this how do I send this as a command to the other
ListView's scrollbar?


Thanks!

Nicholas Paldino said:
MrNobody,

Basically, when you scroll one list view, you can send the LVM_SCROLL
message to the other to make that one scroll as well. You can detect
when
one list view scrolls by overriding the WndProc method and looking for
the
WM_VSCROLL (vertical scroll) message, I believe.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

MrNobody said:
I have two large text boxes side by side which when loaded with text
will
usually get a horizontal scrollbar automatically.

I would like to set it up so that when I scroll a bit to one direction
on
one textbox, the other textbox scrolls in the same direction with the
same
amount...

how to do this?
 
G

Guest

Nicholas,

thanks again for your help!

OK this is starting to get a little bit over my head... (the sending message
part) What do you mean by declaring a SendMessage through a p/invoke layer? I
am totally unfamilar with what the web site is referencing...
 

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