C
C#3w 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...
}
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?
8 Replies
stigzler
stigzlerOP3w ago
Urgh - recently upgraded this project to .net 9. I think it might be that - thanks a bunch MS....
Unknown User
Unknown User3w ago
Message Not Public
Sign In & Join Server To View
stigzler
stigzlerOP3w ago
Designers changes from .NET Framework - Windows Forms
Learn about the Windows Forms designer changes from .NET Framework to .NET.
stigzler
stigzlerOP3w ago
/resolved
Unknown User
Unknown User3w ago
Message Not Public
Sign In & Join Server To View
MODiX
MODiX3w ago
If you have no further questions, please use /close to mark the forum thread as answered
stigzler
stigzlerOP3w ago
Thanks for your really helpful and constructive views, ToBeCo. You da man. [what a Richard Cranium]

Did you find this page helpful?