Prevent PropertyGrid item from being reset

3 posts, 1 answers
  1. Paul
    Paul avatar
    23 posts
    Member since:
    Feb 2013

    Posted 26 Jun 2013 Link to this post

    I want to prevent a user from using the property grid context menu to reset a value that has changed. I tried setting the IsModified property to false, but it is read-only. Is there another way to make sure the "Reset" item in the context menu is always disabled for a specific property grid item?
  2. Answer
    Dimitar
    Admin
    Dimitar avatar
    1415 posts

    Posted 28 Jun 2013 Link to this post

    Hello Paul,

    Thank you for writing.

    The easiest way to ensure that all elements values in the grid cannot be reset is this:
    radPropertyGrid1.RadContextMenu.Items[0].Visibility = Telerik.WinControls.ElementVisibility.Collapsed;

    If you want to disable the reset for a specific item you need two things:
    • Handle the RadContextMenu DropDownOpened event
    • Disable the menu reset option for the specific element
    Here is the corresponding code for the steps: 
    void RadContextMenu_DropDownOpened(object sender, EventArgs e)
    {
        if (this.radPropertyGrid1.SelectedGridItem.Name == "BorderColor")
        {
            radPropertyGrid1.RadContextMenu.Items[0].Enabled = false;
        }
    }

    I hope this helps.

    Regards,
    Mitko
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Paul
    Paul avatar
    23 posts
    Member since:
    Feb 2013

    Posted 28 Jun 2013 Link to this post

    That is what I was looking for. Thanks.
Back to Top