Example #1
0
    public override object EditValue(ITypeDescriptorContext context, System.IServiceProvider provider, object value)
    {
        IWindowsFormsEditorService svc = provider.GetService(typeof(IWindowsFormsEditorService)) as IWindowsFormsEditorService;
        Foo foo = value as Foo;

        if (svc != null && foo != null)
        {
            using (FooForm form = new FooForm())
            {
                form.Value = foo.Bar;
                if (svc.ShowDialog(form) == DialogResult.OK)
                {
                    foo.Bar = form.Value;     // update object
                }
            }
        }
        return(value);    // can also replace the wrapper object here
    }
    public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
    {
        var    svc  = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
        string text = value as string;

        if (svc != null && text != null)
        {
            using (FooForm form = new FooForm())
            {
                form.Value = text;
                if (svc.ShowDialog(form) == DialogResult.OK)
                {
                    return(form.Value);
                }
            }
        }
        return(value);
    }
    public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
    {
        var    svc    = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
        MyType myType = value as MyType;

        if (svc != null && myType != null)
        {
            using (FooForm form = new FooForm())
            {
                form.Value = myType.Bar;
                if (svc.ShowDialog(form) == DialogResult.OK)
                {
                    myType.Bar = form.Value;     // update object
                }
            }
        }
        return(value);
    }
    public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
    {
        var svc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
        Foo foo = value as Foo;

        if (svc != null && foo != null)
        {
            using (FooForm form = new FooForm())
            {
                form.Value = foo.Value;
                if (svc.ShowDialog(form) == DialogResult.OK)
                {
                    // Updates the value of the property Value
                    // of the property we're editing.
                    foo.Value = form.Value;
                }
            }
        }
        // In this case we simply return the original property
        // value, the property itself hasn't been changed because
        // we updated the value of an inner property
        return(value);
    }
Example #5
0
 private Task OnValidSetError(EditContext context)
 {
     FooForm.SetError <Foo>(f => f.Name, "数据库中已存在");
     return(Task.CompletedTask);
 }