Invoke Property Editor

Ok This is a simple question I hope.

I want to be able to invoke a controls property editor.

For example in VS.Net you select the control then select font and it shows the font dialog box. 

I want to be able to invoke that controls font property editor (the font dialog) from code.

Is there a way to do this

Joe


Answer this question

Invoke Property Editor

  • Filipe Janela

    Ok, I'm still working on this issue, though I don't see how I can upload my example project.

    I have a custom property and I have a custom UITypeEditor on that property. I need to be able to invoke this though a vs.net plugin

    Let me know if you want the example project and I'll email it to yea.

    Please I really need to find an answer

    Joe

  • Lisa Morgan

    Is there any idea's on this thread

    HELP!!!!!!!!!!!!!!!!!!!!

  • Urip

    Hello,

    For this you will have to write a UITypeEditor. For example you want to show a custom type editor to select a number (or byte). The example below shows how to write a custom editor of type Modal form. Note that this custom editor is only for illustration and always returns the value 3.

    public class MyUITypeEditor : UITypeEditor
    {
    private IWindowsFormsEditorService edSvc = null;
    public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
    {
    edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
    Form f = new Form();

    f.BackColor = Color.Blue;
    f.Text = "Wow Editor"; 
    edSvc.ShowDialog(f);
                                                    // Your logic here
    return (byte)3;
    }
    public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
    {
    return UITypeEditorEditStyle.Modal;
    }

    }

    Now that you have a custom TypeEditor you have to hook this up to your property. Say for example we have a property Wow for which we want to use this editor. Code snippet:

    [Editor(typeof(MyUITypeEditor), typeof(UITypeEditor))]
    public byte Wow
    {
    get
    {
    return _wow;
    }
    set
    {
    _wow = value;
    }
    }


    Now if you were to select Wow in the property grid you could bring up your custom type editor.

    Hope that halps!

    -Dinesh Chandnani

  • BW88159

    If I get it right, it seems like you want to be listening to ComponentAdded event of the ComponentChangeService. If so then when a component is added you can bring up the editors you want and set the properties depending on what the users select in the editor. If you want to be able to do this for a custom control that you are writing then you can do so by having a custom tool box item associated with this control. 

    Hope that helps!

    -Dinesh Chandnani

  • Brian Leach

    Sorry.  Took a little looking but now I see I used new instead of override.
  • Ali883945

    CustomToolBox Item

    I am using the componentchangeservice that's how I know when a new control is added. I then run this wizard and pass the component in question. The problem is I want to be able to invoke the custom editors I built for the control instead of having the user hit the property grid.

    Will this custom toolbox item do the trick

    Thanks

    Joe

  • Seclymer

    Interesting problem.  

    I have done the above along with having a Paint processing for the value and a drop down form for building the values (the property actually consists of three values).  The interesting part is that the Paint does get invoked but the processing for the drop down never occurs.

    A partial listing is:

    public class FillEditor : UITypeEditor {
    private IWindowsFormsEditorService editorService = null;
    public new UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context) {
    return UITypeEditorEditStyle.DropDown;
    }
    public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) {
    FillEditorUI editor;
    bool reverse;
    Fill Filler;

    if ((null != context) &&
    (null != context.Instance) &&
    (null != provider)){
    editorService = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
    if (null != editorService){
    Filler= (Fill)value;
    reverse = getReverseValue(context);
    editor = new FillEditorUI(editorService, Filler, reverse);
               
    editorService.DropDownControl(editor);
    value = editor.GetValue();
    }
    }
    return value;
    }
    public override bool GetPaintValueSupported(ITypeDescriptorContext context) {
    return true;
    }
    public override void PaintValue(PaintValueEventArgs e) {
    LinearGradientBrush brush = null;
    Fill filler;

    filler = (Fill)e.Value;
    if (null != filler){
    try{
    brush = blender.GetLinearGradientBrush(e.Bounds);
    e.Graphics.FillRectangle(brush, e.Bounds);
    }
    finally{
    if (null != brush)
    brush.Dispose();
    }
    }
    }

    I have even run through the debugger to see if the code was failing on execution but the code was never invoked.  

    Any ideas

  • Jun Fang

    Thanks, though I know about what you sent, I use it all over the place.

    I still don't have an aswer to my problem.

    Ok basicly I have a plugin for vs.net if you will. and when they use the plug in it will go though a list of pre-determed items for the selected control

    For example Lets say when a user drops the button control on to the form

    I want to then use this plugin when clicked it will do the following

    ask what 
    fore color
    back color
    Font
    Text

    Kind of like a little wizard for every control.

    Now I know I could make my own classes to bring up the front dialog and such, but I want to be able to bring up the font dialog the property grid uses.

    You see I have some complex controls and I want to be able to brint up thier editors like the one you gave me. I have custom editors for different properties that show different forms. 

    Now I just need to be able to call up those same editors from my plugin of the selected control.

    I don't want the user to click the property grid to show the editors I want to bring them up using my plug in.

    Hope I got this though better

    Joe

  • Invoke Property Editor