Add link to Collection Property in Property Window

80 views Asked by At

I'm creating a User control using .net and i have custom properties on this control. How can i make a link to the property(red square) visible with the description at the bottom of the property window of the control like in the picture below to acces it more easy(on the yellow square)

Text

I've tried to use some System.ComponentModel Attributes to the property but no luck so far...

<System.ComponentModel.Description("Editar ListaColumnasCO")>
<System.ComponentModel.EditorBrowsable(True)>
<System.ComponentModel.ComVisible(True)>
<System.ComponentModel.SettingsBindable(True)>
Public Property ListaColumnasCo() As List(Of ColumnaCo)

Any ideas?

1

There are 1 answers

5
Mo Khalefa On

Here is a simple example to make Verbs [add a reference of System.Design]

Imports System.ComponentModel
Imports System.ComponentModel.Design

<Designer(GetType(MyButton.MyButtinDesigner)), DefaultProperty("Text2")>
Class MyButton
    Inherits Button

    Dim mText2 As String = "Text 2"
    ''' <summary>
    ''' You'll see this description on Editor while typing 
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    <DefaultValue("Text 2"), Category("Text"), Description("description for Properties Explorer")>
    Property Text2 As String
        Get
            Return mText2
        End Get
        Set(value As String)
            mText2 = value
        End Set
    End Property

    Class MyButtinDesigner
        'Add reference 'System.Design' 
        Inherits System.Windows.Forms.Design.ControlDesigner

        Public Overrides ReadOnly Property Verbs As DesignerVerbCollection
            Get
                Return MK_Verbs()
            End Get
        End Property

        Dim _Verbs As System.ComponentModel.Design.DesignerVerbCollection
        Private Function MK_Verbs() As System.ComponentModel.Design.DesignerVerbCollection
            If _Verbs Is Nothing Then
                _Verbs = New System.ComponentModel.Design.DesignerVerbCollection
                _Verbs.Add(New DesignerVerb("My Shortcut", AddressOf MyShortcut))
            End If
            Return _Verbs
        End Function

        Sub MyShortcut()
            Dim xMyButton As MyButton = DirectCast(Me.Control, MyButton)
            MessageBox.Show(xMyButton.Text2)
        End Sub
    End Class


<Serializable>
Structure myStruc
    Property Text As String
    Property Color As Color
End Structure

Dim myColl As Collections.ObjectModel.Collection(Of myStruc)

<DesignerSerializationVisibility(DesignerSerializationVisibility.Content)>
<Editor(GetType(CollectionEditor), GetType(System.Drawing.Design.UITypeEditor))>
ReadOnly Property myCollection As Collections.ObjectModel.Collection(Of myStruc)
    Get
        If myColl Is Nothing Then myColl = New Collections.ObjectModel.Collection(Of myStruc)
        Return myColl
    End Get
End Property


End Class