Click here to Skip to main content
15,886,766 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to create an user control very very similar to Combo Box. In user application I have added the control, in design mode the string collection editor opens up by clicking the Eclipse. I add few lines. How do I retrieve these values. What happens when OK button is clicked or cancel button of string editor's is clicked. See, Items property is having Get and Set. How to set the items from string collection editor.

What I have tried:

<DesignerSerializationVisibility(DesignerSerializationVisibility.Content)> _
    <Editor("System.Windows.Forms.Design.StringCollectionEditor, System.Design", "System.Drawing.Design.UITypeEditor, System.Drawing")> _
    <Browsable(True)> _
    Public Property Items() As Collection
        Get
            Return P1Value
        End Get
        Set(ByVal value As Collection)
            For Each Str As String In value
                Me.Items.Add(CType(Str, String))
            Next
            P1Value = value
            AddItemsOnForm(P1Value)
        End Set
    End Property

    Private Sub AddItemsOnForm(ByVal MC As Collection)
        For I As Integer = 1 To P1Value.Count
            Dim MyLabel As New Label
            With MyLabel
                .Text = P1Value.Item(I)
                .Top = MTop
                .Left = 1
                MsgBox("Item = " & P1Value.Item(I))
            End With
            MyForm.Controls.Add(MyLabel)
            MTop = MTop + 14
        Next
    End Sub
Posted
Comments
[no name] 8-Jan-21 22:28pm    
You should rethink why you're using a custom CB that's very similar to a real CB but that you can't get to do what you want.
RickZeeland 9-Jan-21 1:04am    
DesignerSerialization is a very difficult thing, I once tried it (CodeProject: Beveled Panel with Shadow Effect - Now With Tabs) but had to give up.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900