-2

I work with Visual Studio 2022 and .Net 6. I'm trying to make a control with Verbs. If I press the right mouse button on the control in the designer, there should be a menu The code I found on the page below should do this.

https://learn.microsoft.com/en-us/dotnet/api/system.componentmodel.design.designerverb?view=net-6.0

  • I first created a.net 6 Windows Forms App
  • And then I added a Windows Forms class library to the solution.
  • I copied and pasted the code on the page above into the class in the class library.
  • Then I saved everything.
  • Then I close all tabs and do clean and build.
  • When the designer of the form(of the windows forms app) is open then I see the control in the toolbox
  • I put the new control on the form and press the right mouse button when my mousepointer is on the control but the verbs don't come into view. What am I doing wrong.

I expect verbs to be displayed in the popup menu of the control, But they don't become visible. Below you can see the code that is relevant for me:

m_Verbs = new DesignerVerbCollection();
        
m_Verbs.Add( new DesignerVerb("First Designer Verb", new EventHandler(OnFirstItemSelected)) );
m_Verbs.Add( new DesignerVerb("Second Designer Verb", new EventHandler(OnSecondItemSelected)) );

Click on this link to see the menu without the 2 verbs

ActiveS
  • 1
  • 1
  • 3
  • Hi, can you provide a minimal reproducible example? Usually, following the official document steps, there will be no problem that the predicate is not displayed in the pop-up menu of the control. There is a possibility that it is a problem with the custom control itself, which requires you to provide more information. – wenbingeng-MSFT May 24 '23 at 09:01
  • The code is on the Microsoft web page I linked. I have followed the instructions in the comment in the code. I don't know how to get the code working. I can show everything I have made, but then I have to copy code from the Microsoft website to this topic and I don't know if that is allowed. The steps I've done. I have described in the problem statement of this topic – ActiveS May 26 '23 at 18:41
  • How can I use the debugger in design time so I can see where the problem exactly occurs? – ActiveS May 26 '23 at 18:58

1 Answers1

0

I have found an answer. I got it working with .Net Framework 4.8 but not with .Net 6.0.

  • First I created a class library in .NET Framework (4.8).

  • And then a Windows Forms App (.NET Framework 4.8)

  • I have added C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.8\System.Design.dll to the references of the Class Library.

  • Then I make a reference from the Windows Forms App to the class library.

  • And then I close the tabs

  • I do clean and build and now the verbs do appear in the menu.

Click here to see picture with the result

If anyone knows why this compiles well in .NET 6 without the System.Design.dll but doesn't work properly, that would be useful to know, but this will at least work with .NET 4.8.

Jeremy Caney
  • 7,102
  • 69
  • 48
  • 77
ActiveS
  • 1
  • 1
  • 3
  • This doesn’t seem to answer your original question, though, which was about .NET 6. Am I misunderstanding? – Jeremy Caney May 27 '23 at 00:57
  • 1
    You're right. It should work in .Net 6.0, but because that didn't work I tried it with .Net Framework 4.8 and that didn't work at first either. But since it works now in .Net Framework 4.8 I made a post about it in this topic. So it's true that my question hasn't really been answered yet. – ActiveS May 27 '23 at 09:21