Mousewheel handling somewhat different than expected

Getting the mouse wheel works somewhat different than expected.

  1. The event can not be added from the designer so it needs to be added manually. MouseWheel += … This is easy since the implementation is generated automatically (Two TAB presses)
  2. The mouse wheel messages are send to the control which has the current focus. If the control does not support receiving focus use the parent to add the event handler to. For example, in case of a Panel add the event handler to the Form.
Lastest update in May 2011, inital post in May 2011

Disable a toolbar or ToolStripPanel

Individual toolbars / toolstrips can be disabled by using the enabled property.

When in a ToolStrip in inside a ToolStripContainer the entire panel (and the hosted toolstrips) can be disabled all at once.

For example
toolStripContainer1.TopToolStripPanel.Enabled = false;
toolStripContainer1.BottomToolStripPanel.Enabled = false;
toolStripContainer1.LeftToolStripPanel.Enabled = false;
toolStripContainer1.RightToolStripPanel.Enabled = false;

Note:
Do not disable the toolStripContainer1 since it will also disable the hosted panel in the center.

Lastest update in May 2011, inital post in May 2011

Enabling keyboard input on Forms

By default forms do not get keyboard input.

To allow keyboard input set the forms  KeyPreview property to true.

This will enable the firing of the  KeyDown and  KeyUp events.

Lastest update in May 2011, inital post in May 2011

Legal notice (use of the content of this blog)

Content

The content inside this blog is provided “as is” without any warranties. The content may contain inaccuracies or even be plain incorrect.

Copyright

The content is copyrighted. Any form of (partial) distribution except for personal or in-company use is prohibited.

Other use of the content, including source code, is free for both personal and commercial use.

Lastest update in May 2011, inital post in May 2011