Monday, March 12, 2012

Possible values for custom property in combobox

I have a custom property and want to offer the possible values at designtime in the property sheet or editor in a combobox. I there a way I can accomplish this? Or do I have to make a custom UI for this?

Thanks,
HenkHave a look at the updated BOL topic Doug posted for your earlier (http://forums.microsoft.com/msdn/ShowPost.aspx?PostID=74057).

You probably want to use an enumeration to define the values, and set a TypeConverter as per the example in BOL.

For more advanced properties, or where you want a fancy UI, then set a UITypeEditor instead. There are a few more UITypeEditors in the box (Framework 2.0) now as well -

UITypeEditor Hierarchy
(http://msdn2.microsoft.com/library/bfc7teys(en-us,vs.80).aspx)|||Thanks Darren, I missed the post (and a valuable one!) indeed. Unfortunately I can't use an enumeration, because I need to determine the possible values dynamically from a table. Guess, that if I will persue this, I need an UITypeEditor

Regards,
Henk|||You can write a TypeConverter with dynamic values, but for more interaction
you will need a UITypeEditor. For example on tasks that consume connections, I use a custom UITypeEditor to display a drop-down of connections, and offer a <new connection> option. This needs you own code to do, as I want to do fancy stuff when selecting the new option.

It may be easier to do in a custom UI rather than through the advanced UI. You can provide a richer user experience, especially when there are interactions between several properties. Talking to other properties can be done by working through the context reference you get, but it can be a pain.

There are plenty of articles out there on Property Grids, and converters/editors, and the underlying concepts have been around for a while, totally unrelated to SSIS, so be sure to check out regular .Net resources too, e.g.

The Code Project - PropertyGrid and Drop Down properties - C# Programming
(http://www.thecodeproject.com/csharp/DropDownProperties.asp)

No comments:

Post a Comment