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

Prevent PropertyGrid item from being reset

2 Answers 214 Views
PropertyGrid
This is a migrated thread and some comments may be shown as answers.
Paul
Top achievements
Rank 1
Paul asked on 26 Jun 2013, 06:20 PM
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 Answers, 1 is accepted

Sort by
0
Accepted
Dimitar
Telerik team
answered on 28 Jun 2013, 03:56 PM
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 >>
0
Paul
Top achievements
Rank 1
answered on 28 Jun 2013, 04:13 PM
That is what I was looking for. Thanks.
Tags
PropertyGrid
Asked by
Paul
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Paul
Top achievements
Rank 1
Share this question
or