I am trying to validate a change to a property from within a propertygrid that requires a password. I am trying to capture the ValueChanging event for the underlying editor. If a form is launched from within the event handler and the change is not cancelled, an ArgumentOutOfRangeException ends up being thrown sometime after the event handler returns. I have attached a simple example that throws the exception. In it there is a simple Yes/No message box. If Yes is answered -> Exception is thrown. Any help is much appreciated. Thank you
Enum type and simple class edited by the Property Grid.
public enum EnumeratedProp { FirstItem, SecondItem, ThirdItem}public class TestProps{ [DisplayName("Formula Lock Active")] [Description("Indicates whether custom formulas can be locked to prevent editing")] public EnumeratedProp TestProp { get; set; }}
Form Code
public partial class TestPropsForm : Form{ public TestProps tstProps = new TestProps(); public TestPropsForm() { InitializeComponent(); radPropGrid.SelectedObject = tstProps; } private void radPropGrid_EditorInitialized(object sender, Telerik.WinControls.UI.PropertyGridItemEditorInitializedEventArgs e) { if(e.Item.Name == "TestProp") { e.Editor.ValueChanging += TestProp_ValueChanging; } } private void TestProp_ValueChanging(object sender, Telerik.WinControls.UI.ValueChangingEventArgs e) { e.Cancel = (MessageBox.Show("Are you sure you want to change this?", "Question", MessageBoxButtons.YesNo) != DialogResult.Yes); }}