question

ChristKingKennedy-5906 avatar image
0 Votes"
ChristKingKennedy-5906 asked DavidBowser-7479 edited

ContextMenu not recognized by IDE

I'm using a class that I've been working on for months and it suddenly (in a new project) has a major problem and cannot find

System.Windows.Forms.ContextMenu

here's a pic of my screen
101088-contextmenu.png

I am working with .Net 5.0 which, for me, is new.... so that might be the problem. dunno

any idea what assembly reference I'm missing? what I should look for?



dotnet-csharp
contextmenu.png (101.3 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

DanielZhang-MSFT avatar image
0 Votes"
DanielZhang-MSFT answered DavidBowser-7479 edited

Hi ChristKingKennedy-5906,
The ContextMenu class is not available in .NET Core 3.1 and later versions. You can use ContextMenuStrip instead, which replaces and extends the ContextMenu control.

 System.Windows.Forms.ContextMenuStrip cm = new System.Windows.Forms.ContextMenuStrip();

More details please refer to this document.
Best Regards,
Daniel Zhang


If the response is helpful, please click "Accept Answer" and upvote it.

Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

I said all that. The document I referred to says that ContextMenuStrip is the replacement.

0 Votes 0 ·

So why does Microsoft's documentation say that 'ContextMenuStrip' is not supported on .NET 5 ?

https://docs.microsoft.com/en-us/dotnet/api/system.windows.forms.contextmenustrip?view=windowsdesktop-6.0&viewFallbackFrom=net-5.0

In fact, if I select any .NET Core 3.1 or later it says it is not supported yet and only WindowsDesktop is supported.

0 Votes 0 ·
SimpleSamples avatar image
0 Votes"
SimpleSamples answered
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.