Unplanned
Last Updated: 30 Mar 2016 10:45 by ADMIN
ADMIN
Dess | Tech Support Engineer, Principal
Created on: 28 Sep 2015 06:58
Category: PropertyGrid
Type: Bug Report
1
FIX. RadPropertyGrid - hiding the "Sort" context menu item in the ContextMenuOpening event doesn't work
To reproduce:

public Form1()
{
    InitializeComponent();
    this.radPropertyGrid1.SelectedObject = this;

    this.radPropertyGrid1.ContextMenuOpening += radPropertyGrid1_ContextMenuOpening;
}

private void radPropertyGrid1_ContextMenuOpening(object sender, Telerik.WinControls.UI.PropertyGridContextMenuOpeningEventArgs e)
{
    foreach (RadItem item in e.Menu.Items)
    {
        if (item.Text == "Sort")
        {
            item.Visibility = ElementVisibility.Collapsed;
            item.PropertyChanged += item_PropertyChanged;
        }
    }
}

Workaround:
private void radPropertyGrid1_ContextMenuOpening(object sender, Telerik.WinControls.UI.PropertyGridContextMenuOpeningEventArgs e)
{
    RadItem item = null;
    for (int i = 0; i < e.Menu.Items.Count; i++)
    {
        item = e.Menu.Items[i];
        if (item.Text=="Sort")
        {
            e.Menu.Items.Remove(item);
        }
    } 
}
0 comments