Base class for dropdown editors

Namespace: Dapfor.Net.Editors
Assembly: Dapfor.Net (in Dapfor.Net.dll) Version: 2.10.3.24917 (2.10.3.24917)

Syntax

C#
public abstract class DropDownEditor : UITypeEditorEx
Visual Basic
Public MustInherit Class DropDownEditor
	Inherits UITypeEditorEx
Visual C++
public ref class DropDownEditor abstract : public UITypeEditorEx
F#
[<AbstractClassAttribute>]
type DropDownEditor =  
    class
        inherit UITypeEditorEx
    end

Remarks

Demonstrates how to implement editor that shows "Yes/No" in drop-down list.
 Copy imageCopy
//Implementation of a drop-down editor that modifies boolean values
public class YesNoEditor : DropDownEditor
{
    private const string noString = "No";
    private const string yesString = "Yes";

    public override void Populate(ListBox listBox, object value, ref ContentAlignment alignment)
    {
        listBox.Items.Add(yesString);
        listBox.Items.Add(noString);
    }

    public override object EndEdit(ListBox listBox, object value)
    {
        if (Equals(yesString, listBox.SelectedItem)) return true;
        if (Equals(noString, listBox.SelectedItem)) return false;
        return value;
    }

    public override bool GetPaintCellSupported()
    {
        return true;
    }

    public override void PaintCell(PaintCellEventArgs e)
    {
        //Replace "True/False" by "Yes/No" drawing
        e.Text = Equals(true, e.Cell.Value) ? yesString : noString;

        //Default drawing
        base.PaintCell(e);
    }
}

Inheritance Hierarchy

See Also