Public Class CustomEditor
Inherits System.Drawing.Design.UITypeEditor
Public Overrides Function GetEditStyle(ByVal context As System.ComponentModel.ITypeDescriptorContext) As System.Drawing.Design.UITypeEditorEditStyle
Return Drawing.Design.UITypeEditorEditStyle.DropDown
End Function
Public Overrides Function EditValue(ByVal context As System.ComponentModel.ITypeDescriptorContext, ByVal provider As System.IServiceProvider, ByVal value As Object) As Object
Dim ui As New System.Windows.Forms.CheckedListBox
ui.Items.Add("ABC")
ui.Items.Add("DEF")
ui.Items.Add("GHI")
ui.CheckOnClick = True
ui.BorderStyle = Windows.Forms.BorderStyle.None
Dim I As MyClass = context.Instance
If I.MyStringProp <> "" Then
Dim f() As String = I.MyStringProp.Split(",")
For Each s As String In f
If ui.Items.IndexOf(s) <> -1 Then ui.SetItemChecked(ui.Items.IndexOf(s), True)
Next
End If
Dim fr As System.Windows.Forms.Design.IWindowsFormsEditorService = provider.GetService(GetType(System.Windows.Forms.Design.IWindowsFormsEditorService))
fr.DropDownControl(ui)
Dim s2 As String
For Each s3 As String In ui.CheckedItems
s2 = s2 & s3 & ","
Next
If Right$(s2, 1) = "," Then s2 = Left$(s2, Len(s2) - 1)
ui.Dispose()
Return MyBase.EditValue(context, provider, s2)
End Function
End Class