Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / WinForms > PropertyGrid > Wrong PropertyData Make Program Dead

Not answered Wrong PropertyData Make Program Dead

Feed from this thread
  • Ji -Won avatar

    Posted on Jan 26, 2012 (permalink)

    Hi.. 
    Im using PropertyGrid for my own class.
    that class have nonbasic type..
    that type is kind of class. ex) Point,SizeF
    If I try change Some Data at unexpand mode
    Look at example picture.
    at there if I write some bad string like "20,A"
    in typeconverter make exception but that exception make program dead.
    system.windows.form.propertygrid just show popupmessage.
    but radpropertygrid make program dead.

    even RadControl Demo also Dead.. please tell me about solution or fix that bug..
    thanks...

    Attached files

    Reply

  • Ivan Petrov Ivan Petrov admin's avatar

    Posted on Jan 31, 2012 (permalink)

    Hi Ji-Won,

    Thank you for writing.

    The reason why the exception is thrown and not internally handled is because we try to give as much flexibility to the developer as possible. This is why we have a validation mechanism where you can take care of the validation. You can read more about validation with RadPropertyGrid in our online documentation.

    Here is an example of how you can validate the case you have described using the PropertyValidating event:
    private void radPropertyGrid1_PropertyValidating(object sender, PropertyValidatingEventArgs e)
    {
      PropertyGridItem item = e.Item as PropertyGridItem;
     
      if (item == null)
      {
        return;
      }
     
      if (item.PropertyType == typeof(Point))
      {
        try
        {
          TypeConverter converter = item.TypeConverter;
          converter.ConvertFrom(e.NewValue);
        }
        catch (Exception ex)
        {
          e.Cancel = true;
          item.ErrorMessage = ex.Message;
          return;
        }
     
        item.ErrorMessage = String.Empty;
      }
    }

    I hope this will be useful for you. If you have further question, I would be glad to help.

    Kind regards,
    Ivan Petrov
    the Telerik team

    SP1 of Q3’11 of RadControls for WinForms is available for download (see what's new).

    Reply

  • Say Hello to Telerik's PivotGrid for ASP.NET AJAX, Silverlight, WPF and WinForms. Now packed with OLAP support.

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / WinForms > PropertyGrid > Wrong PropertyData Make Program Dead