Groups | Blog | Home
all groups > dotnet windows forms designtime > january 2005 >

dotnet windows forms designtime : bool - checkbox on design-time


choyk1
1/3/2005 4:47:05 PM
Hi all,

How can I show checkbox for bool properties of my custom control in
design-time. The usage of 'DesignerVerb' shows just plain MenuItem.
I am wondering how TextBox control shows a CheckBox for MultiLine option,
for example. (See a TextBox control and its MultiLine option in VS.NET 2005
WinForm design mode)

Ulrich Sprick
1/8/2005 7:13:42 PM
Hi,
this one is easy (I hope):
1. Create an editor for such a property, and derive from UITypeEditor
2. Override GetEditStyle() and return UITypeEditorEditStyle.Dropdown I think
this should work.
3. Override EditValue() to dropdown a Listbox with the two strings, true and
false.
4. Override GetPaintValueSupported() and return true to indicate that you'd
like to paint a little checkbox.
5. Override PaintValue() to to the painting in the value cell of the
property. The Drawing namespace has static methods that paints buttons, I
think there should be one that paints a checkbox image. The PaintValue()
arguments provide everything needed for painting.
6. Decorate your bool property with the [Editor( typeof( yourEditorClass ),
typeof( UITypeEditor ))]. This associates the editor with your property.

There is a tutorial in the msdn documents, entitled "Enhancing Design-Time
Support" which has a link to a working sample.

HTH, ulrich

"choyk1" <choyk1@discussions.microsoft.com> schrieb im Newsbeitrag
news:252E4523-AC51-450A-BDAE-D6C53E438657@microsoft.com...
[quoted text, click to view]

AddThis Social Bookmark Button