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

Wrong PropertyData Make Program Dead

1 Answer 48 Views
PropertyGrid
This is a migrated thread and some comments may be shown as answers.
Ji -Won
Top achievements
Rank 1
Ji -Won asked on 27 Jan 2012, 02:20 AM
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...

1 Answer, 1 is accepted

Sort by
0
Ivan Petrov
Telerik team
answered on 31 Jan 2012, 10:04 AM
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).

Tags
PropertyGrid
Asked by
Ji -Won
Top achievements
Rank 1
Answers by
Ivan Petrov
Telerik team
Share this question
or