C#C
C#8mo ago
stigzler

✅ ParentControlDesigner not creating Verbs on UserControl/Winforms

Not sure what's wrong with the below. It's meant to create two verbs (i.e. links/controls in the propertyGrid in VS2022) on the custom control "Wizard" - however, these are not showing up. Code:
internal class WizardDesigner : ParentControlDesigner
{

    public override void Initialize(System.ComponentModel.IComponent component)
    {
        base.Initialize(component);
    }

    DesignerVerbCollection fVerbs;
    public override DesignerVerbCollection Verbs
    {
        get
        {
            if (fVerbs == null)
                fVerbs = new DesignerVerbCollection(new DesignerVerb[]
                    {
                        new DesignerVerb("Add Wizard Page", OnAdd) ,
                        new DesignerVerb("Remove Selected Page", OnRemove),
                    }
                );
            return fVerbs;
        }
    }

    void OnAdd(object sender, EventArgs e)
    {
        var wizard = ((Wizard)this.Control);
        wizard.AddNewWizardPage();
    }

    void OnRemove(object sender, EventArgs e)
    {
        var wizard = ((Wizard)this.Control);
        wizard.RemoveSelectedWizardPage();
    }
}

[Designer(typeof(WizardDesigner))]
public partial class Wizard : BaseUserControl
{
    // blah...
}

There's nothing in BaseUserControl that will be confounding it - any ideas?
Was this page helpful?