I have a custom control with a property called Offset that is type PointF.
I want to be able to edit the property from the Form Designer (it is currently disabled).
I read that I must add the EditorAttribute which points to a class derived from System.Drawing.Design.UITypeEditor.
It looks like there are quite a few built in types that derive from UITypeEditor already such as:
System.ComponentModel.Design.BinaryEditor
System.ComponentModel.Design.CollectionEditor
System.ComponentModel.Design.DateTimeEditor
System.ComponentModel.Design.MultilineStringEditor
System.ComponentModel.Design.ObjectSelectorEditor
System.Drawing.Design.ColorEditor
System.Drawing.Design.ContentAlignmentEditor
System.Drawing.Design.CursorEditor
System.Drawing.Design.FontEditor
System.Drawing.Design.FontNameEditor
System.Drawing.Design.IconEditor
… etc
I can’t find one for editing a PointF or Point type. It seems like this functionality should already exist since .NET exposes Point/PointF types all the time in the designer.
I’m hoping I don’t have to reinvent the wheel – I want to use the built in UITypeEditor type if it already exists.
Thanks.
You can add a property to a custom control of type
Pointthat allows editing in the control’s property grid using this code:If you try the same sort of approach with a
SizeFyou’ll find there’s no built in .NETTypeConverterfor aPointF. You can create your own though, I found one here (and copy and pasted most of the code below).With a
PointFTypeConverteryou can write a property of typePointFthat’s editable in the property window:Here’s the PointF type converter code found in the article linked above: