public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
 {
     if (context != null && context.Instance != null && provider != null)
     {
         IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
         if (edSvc != null)
         {
             try
             {
                 FormImage dlg = new FormImage();
                 if (edSvc.ShowDialog(dlg) == DialogResult.OK)
                 {
                     Image img = Image.FromFile(dlg.FileName);
                     if (img != null)
                     {
                         return(img);
                     }
                 }
             }
             catch (Exception err)
             {
                 MessageBox.Show(err.Message);
             }
         }
     }
     return(base.EditValue(context, provider, value));
 }
 public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
 {
     if (context != null && context.Instance != null && provider != null)
     {
         IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
         if (edSvc != null)
         {
             try
             {
                 FormImage dlg = new FormImage();
                 dlg.FileName = value as string;
                 if (context.PropertyDescriptor.Attributes != null)
                 {
                     for (int i = 0; i < context.PropertyDescriptor.Attributes.Count; i++)
                     {
                         FileSelectionAttribute fsa = context.PropertyDescriptor.Attributes[i] as FileSelectionAttribute;
                         if (fsa != null)
                         {
                             dlg.SetParams(fsa.Filter, fsa.Title);
                             break;
                         }
                     }
                 }
                 if (edSvc.ShowDialog(dlg) == DialogResult.OK)
                 {
                     value = dlg.FileName;
                 }
             }
             catch (Exception err)
             {
                 MessageBox.Show(err.Message);
             }
         }
     }
     return(value);
 }