我有一个抽象用户控件(baseModule),它具有我计划使用按位比较的属性,以确定该模块支持哪些导出类型。在从baseModule派生的模块的设计器中,我看到了一个组合框,只能选择一个单独的值(Html,Xml等)我想要一个下拉检查列表框,所以我可以选择我想要哪些价值。
如何在VS2008内完成此操作?我见过其他属性支持这个。请参考下面的代码,以便更好地解释我在上面提到的问题中的含义。
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
答案 0 :(得分:1)
您可能希望实施UITypeEditor
。检查this walkthrough,并将自定义类型编辑器中创建的控件(在EditValue
方法覆盖中)交换为CheckedListBox
,并处理从列表框中分配和检索枚举值。然后用EditorAttribute
指出你的类型编辑器来装饰你的用户控件中的属性,你应该好好去。