Hi experts
I''ve created a custom UITypeEditor and associated the Editor to a property of type Panel for an user control and created. It works fine with Get accessor and open my Editor form.But while try to give a Set accessor for the prioperty, the property edit style has been changed to Drop-Down list. I wonder how this is happening.
public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
{
if (context != null && context.Instance != null)
{
return UITypeEditorEditStyle.Modal;
}
return base.GetEditStyle(context);
}
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
{
if (context != null && context.Instance != null && provider != null)
{
if( value.GetType() != typeof(Panel)) return value; object originalValue=value; _context=context; edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService)); if (edSvc != null) {
AssemblyEditorForm collEditorFrm= new AssemblyEditorForm(); //CreateForm();
collEditorFrm.ItemChanged +=new HCLT.E95UI.BaseFramework.AssemblyEditorForm.InstanceEventHandler(collEditorFrm_ItemChanged);
collEditorFrm.ContentPanel =(System.Windows.Forms.Panel) value;
context.OnComponentChanging();
collEditorFrm.ShowDialog();
if(collEditorFrm.Result==DialogResult.OK)
{
MessageBox.Show(collEditorFrm.Result.ToString());
OnCollectionChanged(context.Instance, collEditorFrm.ContentPanel);
context.OnComponentChanged();
MessageBox.Show(collEditorFrm.ContentPanel.Name);
return collEditorFrm.ContentPanel;
}
}
}
//MessageBox.Show (collEditorFrm.ContentPanel.Name );
return value;
}
private void ItemAdded(object sender, object item)
{
if(_context!=null && _context.Container!=null)
{
IComponent icomp=item as IComponent;
if(icomp !=null )
{
_context.Container.Add (icomp) ;
}
}
}
private void ItemRemoved(object sender, object item)
{
if(_context!=null && _context.Container!=null)
{
IComponent icomp=item as IComponent;
if(icomp!=null)
{
_context.Container.Remove(icomp);
}
}
}
protected virtual void OnCollectionChanged(object instance ,object value)
{
if(CollectionChanged !=null)
{
CollectionChanged(this, instance,value);
}
}
protected virtual AssemblyEditorForm CreateForm()
{
return new AssemblyEditorForm();
}
private void collEditorFrm_ItemChanged(object sender, Panel instance)
{
if(_context!=null && _context.Container!=null)
{
if(instance!=null )
{
_context.PropertyDescriptor.SetValue(this, instance);
}
}
}
Thanks,
Arun M