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

RadPropertyGrid throwing ArgumentOutOfRangeException

2 Answers 55 Views
PropertyGrid
This is a migrated thread and some comments may be shown as answers.
Larry
Top achievements
Rank 1
Larry asked on 23 Mar 2017, 06:14 PM

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);
   }
}

2 Answers, 1 is accepted

Sort by
0
Accepted
Dess | Tech Support Engineer, Principal
Telerik team
answered on 24 Mar 2017, 01:31 PM
Hello Larry, 

Thank you for writing.  

I have logged it in our feedback portal and I have added a vote for it on your behalf. You can track its progress, subscribe for status changes and add your comments on the following link - feedback item.

I have also updated your Telerik points.

Currently, the possible solution that I can suggest is to use the RadPropertyGrid.PropertyValueChanging event to confirm the property changing: 

private void radPropertyGrid1_PropertyValueChanging(object sender, Telerik.WinControls.UI.PropertyGridItemValueChangingEventArgs e)
{
    e.Cancel = (MessageBox.Show("Are you sure you want to change this?", "Question", MessageBoxButtons.YesNo) != DialogResult.Yes);
}

 

I hope this information helps. Should you have further questions I would be glad to help.

Regards,
Dess
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Larry
Top achievements
Rank 1
answered on 27 Mar 2017, 04:30 PM
This worked great.  I was making it much harder than I needed to.  Thanks for the quick response.
Tags
PropertyGrid
Asked by
Larry
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Larry
Top achievements
Rank 1
Share this question
or