I created a new Windows Application and added a Panel to the Form.
But, I don't see the MouseWheel event of the Panel.

Panel derives from Control, which has the MouseWheel event.
So why Panel does not have the MouseWheel event ?

Thanks !

Thank you for the advise !
If I will not have a choice I will definitely use this technique.
But, I'm still interested why MouseWheel event does not appear...

You can decorate properties, events, etc with attributes to hide them in the designer.

    // Summary:
    //     Occurs when the mouse wheel moves while the control has focus.
    public event MouseEventHandler MouseWheel;

The event is there but it is not implemented for the panel because you don't focus a panel like you would a textbox or button, and the mousewheel event fires when a control is focused. You probably have something else inside of the panel that you're wanting to scroll around? Explain what you're trying to accomplish in a little more detail.

I understand what you say.
Where is this code taken from ?
What is the meaning of lines 4,5 ?
Here is what I'm trying to do:
I write some kind of painting program.
I draw all shapes inside a Panel. (Is that a good idea ?)
When the mouse wheel is moved, I would like to increase/decrease the pen width of the currently drawing shape.

>> Line 4: [Browsable(false)] :

BrowsableAttribute Class
Specifies whether a property or event should be displayed in a Properties window.
A visual designer typically displays in the Properties window those members that either have no browsable attribute or are marked with the BrowsableAttribute constructor's browsable parameter set to true. These members can be modified at design time. Members marked with the BrowsableAttribute constructor's browsable parameter set to false are not appropriate for design-time editing and therefore are not displayed in a visual designer. The default is true.

>> Line 5: [EditorBrowsable(EditorBrowsableState.Advanced)] :

EditorBrowsableAttribute Class
Specifies that a property or method is viewable in an editor. This class cannot be inherited.
EditorBrowsableAttribute is a hint to a designer indicating whether a property or method is to be displayed. You can use this type in a visual designer or text editor to determine what is visible to the user. For example, the IntelliSense engine in Visual Studio uses this attribute to determine whether to show a property or method.

In Visual C#, you can control when advanced properties appear in IntelliSense and the Properties Window with the Hide Advanced Members setting under Tools | Options | Text Editor | C#. The corresponding EditorBrowsableState is Advanced.

>>Where is this code taken from
In the instructions above it tells you how to view advanced members with intellisense which I don't have hidden. So in the designer I typed:


When your cursor is on the "MouseWheel" word hit F12 and it will navigate to the declaration, where I copied the code I posted here.

>>I draw all shapes inside a Panel. (Is that a good idea ?)
I don't see why not, but I will let one of our resident drawing experts comment on that.

Try capturing the event at the form level and see if the mouse is on top of the panel:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace daniweb
  public partial class frmPenWheelDraw : Form
    private Pen pen;

    public frmPenWheelDraw()

    private void frmPenWheelDraw_Load(object sender, EventArgs e)
      pen = new Pen(Color.Red, 15);
      this.MouseWheel += new MouseEventHandler(frmPenWheelDraw_MouseWheel);

    void frmPenWheelDraw_MouseWheel(object sender, MouseEventArgs e)
      //You want to grab the mouse position and put a breakpoint after that
      //so you can see the values when the event fired
      Point mousePos = Control.MousePosition; 
      Rectangle rect = new Rectangle(this.PointToScreen(panel1.Location), panel1.Size);

      if (rect.Contains(mousePos)) //They're on top of the panel
        pen.Width += (e.Delta > 0 ? 1 : -1);

    private void panel1_Paint(object sender, PaintEventArgs e)
      e.Graphics.DrawLine(pen, new Point(0, 0), new Point(panel1.Width, panel1.Height));

The problem is only the top level form can get the mouse wheel event.