winforms - Create a custom UserControl using c# -


i created custom usercontrol using windows form control library.and want create property of usercontrolwhich can add item it, can select item combobox.

winforms allows create rich design-time environment providing customised editors @ runtime properties define.

for example, if plonk messagequeue component onto winforms form , view properties window, can see property named formatter.

enter image description here

clicking on formatter property displays drop-down box showing preset list of values. example of ui type editor.

enter image description here

one way define enum supported values (it dynamic list if wish).

public enum muppets {     kermit,     misspiggy,     fozzie } 

...then after defining own editor derived uitypeeditor (see msdn link below)

class mymuppeteditor : uitypeeditor { ... } 

...you attach control's property wish have drop-down so:

[category("marquee")] [browsable(true)] [editorattribute(typeof(mymuppeteditor),                  typeof(system.drawing.design.uitypeeditor))] public muppets muppet {get ; set; } 

for more detailed information check out link below.

more

edit: allow dynamic list, try making property string because that's selection bound , during editvalue() when showing selectioncontrol display listbox of dynamic items


Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -