This is a migrated thread and some comments may be shown as answers.

Disable Context Menu on Selected Item

1 Answer 592 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Pelli
Top achievements
Rank 1
Pelli asked on 11 Jun 2015, 11:52 AM

Hi,

 We have a radtreeview with check boxes. Now we want to support radcontextmenu on checked items and dragdrop on selected items. But when we implement context menu , we are getting even on selected item.

How can we disable contextmenu on selected item and enable only if it checked. Please provide your inputs.

Thanks,

Subhashini

1 Answer, 1 is accepted

Sort by
0
Martin Ivanov
Telerik team
answered on 12 Jun 2015, 12:45 PM
Hello Subhashini,

You can prevent the context menu from opening by handling the ContextMenuOpening event of the element on which the menu is attached. For example, if the context menu is attached on the RadTreeView control you can subscribe for its event and set the argument's Handled property to True. Here is an example:
<telerik:RadTreeView ContextMenuOpening="RadTreeView_ContextMenuOpening">
    <telerik:RadTreeView.ContextMenu>
        <ContextMenu>
            <!-- menu items -->
        </ContextMenu>
    </telerik:RadTreeView.ContextMenu>
</telerik:RadTreeView>

private void RadTreeView_ContextMenuOpening(object sender, ContextMenuEventArgs e)
{
    if(the item is selected and is not checked)
    {
        e.Handled = true;           
    }  
}

Please try this approach and let me know if it works for you.

Regards,
Martin
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
TreeView
Asked by
Pelli
Top achievements
Rank 1
Answers by
Martin Ivanov
Telerik team
Share this question
or