ContextMenuStrip property ignored?

SyntaxEditor for Windows Forms Forum

Posted 12 years ago by Matt Whitfield
Version: 4.0.0260
Platform: .NET 2.0
Environment: Windows XP (32-bit)
Avatar
The ContextMenuStrip property seems to be being ignored - well sort of!!

If, in the demo application, I add a contextMenuStrip to MainForm, and set that as the value of the ContextMenuStrip property, then the ContextMenuStrip is shown, but the internal syntax editor context menu strip is shown over the top. So it does show the context menu strip that I specify, but it doesn't stop displaying the inbuilt one.

Hope that's clear enough!

Comments (8)

Posted 12 years ago by Kelly Leahy - Software Architect, Milliman
Avatar
Set DefaultContextMenuEnabled to false on the syntax editor control.

Kelly Leahy Software Architect Milliman, USA

Posted 12 years ago by Matt Whitfield
Avatar
Ok thanks - it's a bit weird though - most other .NET controls i've come across don't behave in this way - they would assume that if ContextMenuStrip was set then DefaultContextMenuEnabled would be false? Is there some strange reason for this?

Thanks for the help...
Posted 12 years ago by Kelly Leahy - Software Architect, Milliman
Avatar
Yeah, personally, I'd consider this a bug. I can't think of a single use-case where someone would want to attach a context menu strip and also have the default one pop up on top of their custom one! Anyway, that's how this control happens to work, and it's the least of my worries that this piece behaves a little wierd. I have much more problems with the way the ContextMenuRequested event works than the fact I have to set DefaultContextMenuEnabled to false!

Kelly Leahy Software Architect Milliman, USA

Posted 12 years ago by Matt Whitfield
Avatar
Ok now i'm worried because I've just used that event to set enabled / disabled, as well as to populate a list of menu sub-members based on a library of snippets... any words of wisdom? :)
Posted 12 years ago by Kelly Leahy - Software Architect, Milliman
Avatar
Well, just let me know if your code works like you expect it to the first time you right-click on the window....

Mine works now, but when I was trying to set the context menu in that event too, it didn't work right if I didn't have the context menu set already before that event fired. The first time the user right-clicked, it wouldn't pop up the menu. It would only pop it up the second and later times (after the code had set ContextMenuStrip to a value).

You'll probably be fine and will never know the difference unless you try to set ContextMenuStrip to different context menus within that event. In that case, I think it will lag you by a right click!

Kelly Leahy Software Architect Milliman, USA

Posted 12 years ago by Matt Whitfield
Avatar
Ok thanks

I don't think i'll have a problem because i'm not switching context menu strips - simply adding / removing items from the existing context menu

Thank you very much for your help - I can see why you're the guru!!
Posted 12 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hey everyone... good conversation here. Per your discussion, we've made two updates for the next maintenance release that should resolve all this:

1) Updated the default SyntaxEditor context menu display code so that it will not automatically occur if there is a ContextMenuStrip set. This one is because that particular code was written back in .NET 1.x days when there was no ContextMenuStrip yet. We never added a check for it in our .NET 2.0 builds.

2) Changed the ContextMenuRequested event so that it fires before the core Win32 code intercepts the context menu message. This allows for proper dynamic updating of the context menu before Windows displays it.

Hope that helps!


Actipro Software Support

Posted 12 years ago by Matt Whitfield
Avatar
Thanks - good to know the history of it too!
The latest build of this product (v2020.1 build 0400) was released 7 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.