tags:

views:

116

answers:

2

hi all,

i have a multiline textbox in my app and when i middle-click to scroll up or down, it doesn't work.

It works in Notepad, but not in my textbox. Does anybody know why? or, if it is possible to programatically begin scrolling in the desired direction when the middle-button's clicked?

A: 

Do you have the ScrollBars property set to Vertical or Both?
For me it's not working only when ScrollBars = None or Horizontal

najmeddine
i have tried setting it to vertical. then horizontal. then both. no matter which one i set, it still doesn't work
baeltazor
are you talking about scrolling the mouse wheel, or clicking on this wheel to have that sort of 4 arrows for auto-scrolling?
najmeddine
nah, I'm talking about clicking on this wheel to have that sort of 4 arrows for auto-scrolling
baeltazor
That feature is not implemented in textBox (and neither notepad (Win XP)). There is a method in TextBox class called `ScrollToCaret()`, may be it can help you.
najmeddine
+1  A: 

To get the mouse wheel scroll thing to work, make your own custom TextBox class that inherits TextBox.

Override the WndProc method.

Look at the message type.

For Message type 0x207 (WM_MBUTTONDOWN), call DefWndProc(ref m); For any other message type, call base.WndProc(ref m);

Then your text box will have middle button scroll.

Normally Windows.Forms overrides the built-in middle button feature of the textbox so the control can have a MouseDown event on the middle button, but that also disables the innate scroll feature. Go back to calling the default window handler, and the textbox gets its scroll feature back.

Dwedit