This is not so easy to do ... but I have a Solution for you - but this Solution has it's Rules.
At first your Property it must be like this :
<TypeConverter(GetType(DropDownConverter))>
Property ProjektDatei As String
Get
Return my_ProjektDatei
End Get
Set(value As String)
my_ProjektDatei = value
End Set
End Property
Private my_ProjektDatei As String = ""
<Browsable(False), EditorBrowsable(EditorBrowsableState.Never)>
<DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)>
Property ProjektDateiArray As String() = {"1", "2", "3", "4"}
As you see my Property is a single String. The Array with your Data is the following Property. To make it work you need a special TypeConverter. This TypeConverter is written by me and you have to add it to your Application :
Imports System.ComponentModel
Public Class DropDownConverter
Inherits StringConverter
Public Overloads Overrides Function GetStandardValuesSupported(ByVal context As ITypeDescriptorContext) As Boolean
Return True
End Function
Public Overloads Overrides Function GetStandardValuesExclusive(ByVal context As ITypeDescriptorContext) As Boolean
Return True
End Function
Private EntriesArray(-1) As String
Public Overrides Function CanConvertFrom(context As System.ComponentModel.ITypeDescriptorContext, sourceType As System.Type) As Boolean
If sourceType Is GetType(String) Then Return True
Return MyBase.CanConvertFrom(context, sourceType)
End Function
Public Overloads Overrides Function GetStandardValues(ByVal context As ITypeDescriptorContext) As StandardValuesCollection
Dim myPD As PropertyDescriptor = Nothing
Dim myAttribute As DropDownConverterDataAttribute = context.PropertyDescriptor.Attributes(GetType(DropDownConverterDataAttribute))
If myAttribute IsNot Nothing Then
myPD = TypeDescriptor.GetProperties(context.Instance)(myAttribute.DataArray)
Else
Dim HostPropertyName As String = context.PropertyDescriptor.Name
Dim HostPropertyArrayName As String = HostPropertyName + "Array"
myPD = TypeDescriptor.GetProperties(context.Instance)(HostPropertyArrayName)
End If
If myPD IsNot Nothing Then
If myPD.PropertyType Is GetType(String()) Then
EntriesArray = myPD.GetValue(context.Instance)
ElseIf myPD.PropertyType Is GetType(List(Of String)) Then
Dim myList As List(Of String) = myPD.GetValue(context.Instance)
ReDim EntriesArray(myList.Count - 1)
For i As Integer = 0 To myList.Count - 1
EntriesArray(i) = myList(i)
Next
ElseIf myPD.PropertyType Is GetType(Collection) Then
Dim myCollection As Collection = myPD.GetValue(context.Instance)
ReDim EntriesArray(myCollection.Count - 1)
For i As Integer = 0 To myCollection.Count - 1
EntriesArray(i) = myCollection.Item(i + 1)
Next
End If
End If
Return New StandardValuesCollection(EntriesArray)
End Function
End Class
<AttributeUsage(AttributeTargets.[Property] Or AttributeTargets.Method)> _
Public Class DropDownConverterDataAttribute
Inherits Attribute
Public Sub New(DataArray_PropertyName As String)
my_DataArray = DataArray_PropertyName
End Sub
Public ReadOnly Property DataArray() As String
Get
Return my_DataArray
End Get
End Property
Private my_DataArray As String
End Class
I suggest you use the code as given ...
Perhaps you have to import also the used Namespaces to your Application.