How to put properties inside another property? VB.net

Asked

Viewed 142 times

1

I would like to know how I can place properties within another property, as in the example below.

Example:

Open/Expanded Font Property

I tried to do many times in various ways, but the closest I could was the below represented:

Imports System.Windows.Forms
Imports System.Drawing
Imports System.Drawing.Design
Imports System.ComponentModel

Namespace ClassTest_ParentProperty

Public Class Class_Parent : Inherits Control
        Public Property MyProperties_Parent As Class_Child


        Public Sub New()
            MyBase.BackColor = Color.DarkSlateBlue
        End Sub
    End Class

    Public Class Class_Child
        Public Var_MyColor As Color = Color.Empty
        Public Var_MyText As New String(Nothing)
        Public Var_MySize As New Size(50, 50)

        Public Property MyColor As Color
            Get
                Return Var_MyColor
            End Get
            Set(value As Color)
                Var_MyColor = value
            End Set
        End Property

        Public Property MyText As String
            Get
                Return Var_MyText
            End Get
            Set(value As String)
                Var_MyText = value
            End Set
        End Property

        Public Property MySize As Size
            Get
                Return Var_MySize
            End Get
            Set(value As Size)
                Var_MySize = value
            End Set
        End Property

    End Class
End Namespace

But with this attempt I only got what is represented below:

The property that does not expand

I searched for several hours for about 3 days, but I couldn’t find what I wanted. So I hope someone can teach me how to do it.

  • This does not seem to make any sense, it is probably starting from a wrong premise. The solution to the problem must be very different.

  • I don’t know if you understood me, but I asked for help to know how I could do what I wanted, I didn’t say the code I put in was right. If you were, you wouldn’t have called for help.

  • What you want doesn’t make sense. Unless it’s not explained correctly

1 answer

1

Put designer type attributes that come from the library itself. NET.

References:

Imports System.ComponentModel

Class declaration Class_Child:

<Browsable(True)>
Public Class Class_Child

Property declaration:

<Browsable(True)>
<Description("Descrição não é necessária."), Category("Appearance")> ' Categoria da propriedade
<EditorBrowsable(EditorBrowsableState.Always)>
Public Property MyProperties_Parent As Class_Child
  • Thank you for trying to help me, but the result was the same, that is to say it was a property that seems to be in Readonly and does not expand.

  • Try placing the <Browsable(True)> attribute on each public member of Class_Child. It might work.

  • 1

    It happens the same way, but I found another way to solve the problem.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.