Unable to assign context menu to radsyntaxeditor

1 Answer 129 Views
ContextMenu SyntaxEditor
Troy
Top achievements
Rank 3
Bronze
Iron
Iron
Troy asked on 07 Feb 2023, 02:26 AM

According to this page: https://docs.telerik.com/devtools/winforms/controls/menus/contextmenu/context-menus

I should be able to assign a radcontextmenu to the contextmenu of the radsyntaxeditor.  However, I'm finding that not to be the case as you can see below.  my contextmenu named ctxMenuEditor is of type radContextMenu.  

The below screenshots should show the problem I think.  Basically, for whatever reason, the radsyntaxeditor doesn't accept the radcontextmenu, just contextmenu object type. 

 

1 Answer, 1 is accepted

Sort by
1
Accepted
Dinko | Tech Support Engineer
Telerik team
answered on 09 Feb 2023, 12:09 PM

Hi Troy,

Thank you for the provided details.

The RadSyntaxEditor control does not expose such property due to the structure of its text area. What you can do instead is to subscribe to the MouseDown event of the control. In the event handler, you can check if the Left Mouse button triggers the event. If yes, you can show your instance of RadContextMenu. Keep in mind that you will need to pass the clicked point in RadSyntaxEditor control.

private void Editor_MouseDown(object sender, MouseEventArgs e)
{
    if(e.Button == MouseButtons.Right)
    {
        this.radContextMenu1.Show(this.editor, this.editor.PointToClient(Cursor.Position));
    } 
}

Give this approach a try and let me know how it goes.

Regards,
Dinko | Tech Support Engineer
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Troy
Top achievements
Rank 3
Bronze
Iron
Iron
commented on 09 Feb 2023, 09:15 PM

This approach works fine, thank you very much!
Tags
ContextMenu SyntaxEditor
Asked by
Troy
Top achievements
Rank 3
Bronze
Iron
Iron
Answers by
Dinko | Tech Support Engineer
Telerik team
Share this question
or