RadPropertyGrid throwing ArgumentOutOfRangeException

3 posts, 1 answers
  1. Larry
    Larry avatar
    6 posts
    Member since:
    Nov 2014

    Posted 23 Mar Link to this post

    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. Answer
    Dess
    Admin
    Dess avatar
    2107 posts

    Posted 24 Mar Link to this post

    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.
  3. Larry
    Larry avatar
    6 posts
    Member since:
    Nov 2014

    Posted 27 Mar Link to this post

    This worked great.  I was making it much harder than I needed to.  Thanks for the quick response.
Back to Top