Extension of UITypeEditor that enables painting in cells and creating any controls over cells.

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

Syntax

C#
public class UITypeEditorEx : UITypeEditor
Visual Basic
Public Class UITypeEditorEx
	Inherits UITypeEditor
Visual C++
public ref class UITypeEditorEx : public UITypeEditor
F#
type UITypeEditorEx =  
    class
        inherit UITypeEditor
    end

Remarks

The following example demonstrates how to customize cell drawing and editing
 Copy imageCopy
public class CheckBoxEditor : UITypeEditorEx
{
    public override bool GetPaintCellSupported()
    {
            return true;
    }
    public override void PaintCell(PaintCellEventArgs e)
    {
        //Prevent from text drawing
        e.Parts &= e.Parts ^ PaintPart.Text;

        //Default drawing
        base.PaintCell(e);

        //Dimensions to draw the check box
        Rectangle bounds = e.Cell.VirtualBounds;
        int len = bounds.Height;
        bounds.X += (bounds.Width - len) / 2;
        bounds.Width = len;

        //The cell is checked
        if (Equals(true, e.Cell.Value))
        {
            ControlPaint.DrawCheckBox(e.Graphics, bounds, ButtonState.Checked | ButtonState.Flat);
        }
        //The cell is not checked
        else if (Equals(false, e.Cell.Value))
        {
            ControlPaint.DrawCheckBox(e.Graphics, bounds, ButtonState.Normal | ButtonState.Flat);
        }
        //There is no value in cell
        else
        {
            ControlPaint.DrawCheckBox(e.Graphics, bounds, ButtonState.Normal | ButtonState.Inactive | ButtonState.Flat);
        }
    }

    public override void EditCell(IGridEditorService service, Cell cell)
    {
        //Updates the value
        object value = cell.Value;
        cell.Value = !Equals(true, value);
    }

    public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
    {
        return UITypeEditorEditStyle.None;
    }
}

Inheritance Hierarchy

See Also