middle-button scrolly thing in textbox

后端 未结 2 1714
难免孤独
难免孤独 2021-01-20 14:42

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 wh

相关标签:
2条回答
  • 2021-01-20 15:22

    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.

    0 讨论(0)
  • 2021-01-20 15:28

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

    0 讨论(0)
提交回复
热议问题