views:

23

answers:

1

I have an abstract user control(baseModule) that has a property that I plan on using a bitwise comparison on to determine what export types are supported by that module. In the designer of a module derived from baseModule, I am presented with a combobox with the ability to just select a single value (Html, Xml, etc.) I would like to be presented with a drop-down checked listbox so I could select which values I want.

How can I accomplish this inside of VS2008? I've seen other properties support this. Please refer to the code below for a better explanation of what I mean in the poorly asked question above.

Public Class ExportTypes
    Public Enum ExportType
        Html = 1
        Xml = 2
        Xls = 4
        Txt = 8
        Pdf = 16
        Rtf = 32
    End Enum
End Class

Public Class baseModule
    Private _SupportedExportTypes As ExportType = 0
    Public Property SupportedExportTypes() As ExportType
        Get
            Return _SupportedExportTypes
        End Get
        Set(ByVal Value As ExportType)
            _SupportedExportTypes = Value
        End Set
    End Property
End Class
+1  A: 

You will probably want to implement a UITypeEditor. Check this walkthrough, and exchange the created control in the custom type editor (in the EditValue method override) to a CheckedListBox, and handle assigning and retrieving the enum values to and from the listbox. Then decorate the property in your user control with an EditorAttribute point out your type editor, and you should be good to go.

Fredrik Mörk
THe links above pointed me in the right direction. Luckily I found a c# project that had done all the work for me and introduced the FlagsAttribute to me for Enums. http://www.codeproject.com/KB/edit/flagenumeditor.aspx?msg=1453046
Dennis