vb.netpanels

In Visual Studio why does a double click on a panel make a paint event? (vb.net)


I'm in VS IDE and when I double click a panel, it generates a paint event instead of a click event. I've tried other controls and they work fine.

Also, this just started happening today. I know that I can go to properties/events and double click the "click" field and it will produce the desired result, but it's a pain in the butt.

forgot to say... I'm using VS 2015

any help appreciated.


Solution

  • DefaultEventAttribute is used to specify the default event for a component. The docs for Panel (and presumably the other WinForms components) don't seem to show the value for the default event attribute, but if you look at the reference source (or decompile it yourself), you can see the value there:

    [
    ComVisible(true),
    ClassInterface(ClassInterfaceType.AutoDispatch),
    DefaultProperty("BorderStyle"),
    DefaultEvent("Paint"),
    Docking(DockingBehavior.Ask),
    Designer("System.Windows.Forms.Design.PanelDesigner, " + AssemblyRef.SystemDesign),
    SRDescription(SR.DescriptionPanel)
    ]
    public class Panel : ScrollableControl {
    

    I suppose the designers for each component pick the most frequently used event as the default, otherwise the base Control class defines a default of Click:

    [
    ComVisible(true),
    ClassInterface(ClassInterfaceType.AutoDispatch),
    DefaultProperty("Text"),
    DefaultEvent("Click"),
    Designer("System.Windows.Forms.Design.ControlDesigner, " + AssemblyRef.SystemDesign),
    DesignerSerializer("System.Windows.Forms.Design.ControlCodeDomSerializer, " + AssemblyRef.SystemDesign, "System.ComponentModel.Design.Serialization.CodeDomSerializer, " + AssemblyRef.SystemDesign),
    ToolboxItemFilter("System.Windows.Forms")
    ]
    public partial class Control :