We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

changing context menu does not work

I've tried to change the context menu of an AutoComplete control but it shows the default context menu (Cut, Copy, Paste) instead of mine.

my code:

AutoComplete createAccountName = new AutoComplete();
ContextMenu cMenuExample = new ContextMenu();
cMenuExample.Items.Add("Change Name");
createAccountName.ContextMenu = cMenuExample;

3 Replies

VR Venkateshwaran Ramdoss Syncfusion Team June 13, 2016 12:29 PM UTC

Hi Barry,

We can hide the default ContextMenu of the AutoComplete by setting the ContextMenu value as Null. The AutoComplete's TextBox can be got using VisualUtils method. We have created a sample for the same, in which have created a new ContextMenu for AutoComplete and set the default ContextMenu of TextBox as Null. Please download the same from the below link.

Sample: AutoCompleteContextMenusample

Venkateshwaran V.R.

BG Barry Gendenshtein June 13, 2016 06:05 PM UTC

Hi, thanks for the fast response. 
Your solution works if the AutoComplete control is not created at runtime, but in my program it does and I receive a "System.NullReferenceException"  since the textBox does not get the reference to the TextBox descendant of the AutoComplete using the VisualUtils method and remains null...
Try creating the AutoComplete control at runtime as I did in my code in the first message.

VR Venkateshwaran Ramdoss Syncfusion Team June 14, 2016 11:20 AM UTC

Hi Barry,

We were able to reproduce the reported issue in version 13.4. However, the issue is already fixed in our latest version 14.1. Can you please upgrade to our latest version 14.1?

Venkateshwaran V.R.

Live Chat Icon For mobile
Up arrow icon