1
Answer

Using the mousewheel properly

chris.rothery

chris.rothery

21y
1.7k
1
I'm quite new to c#, but have been programming for years, not much in windows but a bit of MFC not too long ago. I've got into c# and am having trouble handling the mousewheel properly in my application. I've got a cut down version of what I'm trying to do that is a default project (1 form) with the following code in the form constructor: Panel p = new Panel(); p.AutoScroll = true; p.Dock = DockStyle.Fill; RichTextBox b = new RichTextBox(); b.Width = 500; b.Height = 500; b.Text = "click me, scroll me!!!"; p.Controls.Add(b); this.Controls.Add(p); so, when the text box is too big for the panel, the scroll bars appear. thing is, that the mouse wheel doesn't scroll the panel. If I change the text box for a button, the wheel scrolls up & down. if the vertical scrollbar isn't needed, but the horizontal one is, the mousewheel scrolls left & right. when both are visible, I'd expect the mousewheel button to allow 2d scrolling (as that's what I've set it to in my driver). a friend suggested doing this by hand (mouse button event, change the cursor, mouse move events change the scroll position), but that sounds a bit lame. Anyone got any ideas? (in my real program, the control being scrolled is an opengl window using csgl).

Answers (1)