troubleshooting Question

Userdefined control containing form ctrls: How to set the properties of form ctrls in the designer?

Avatar of mp45
mp45Flag for Germany asked on
Visual Basic.NET
3 Comments1 Solution351 ViewsLast Modified:

we have a userdefined control (called e.g. LabelAndMore) which contains a Label and other controls. When I apply this userdef. ctrl LabelAndMore in eg. a form I need to set the properties of the label.

Of course, we could add properties like Label_Text and Label_AutoSize in LabelAndMore. For a label this would be ok. However, if a more complex control with more relevant properties is needed instead of a label, all its properties would have to be added in LabelAndMore just to mirror the already existing properties of the complex control to LabelAndMore.

Thus we had the idea to add the property

    Public Property Label() As Label
            Return Me.Label1
        End Get
        Set(ByVal value As Label)
            Me.Label1 = value
        End Set
    End Property

in LabelAndMore. At the first glance this approach looks quite fine. When I add a LabelAndMore to e.g. a form and look at the property list of the inserted instance of LabelAndMore, the new property Label shows. It has a plus symbol in front of it. Expanding it one gets all the properties of the label. But unfortunately the designer does not create code in Form1.Designer.vb for the changed properties of the Label within LabelAndMore.

What do we have to do so that changes of the properties of Label in LabelAndMore are added to the code created by the designer?

I guess it is possible because a split container does it. It consists two panels called Panel1 and Panel2 and the changes of their properties are added in the code created by the designer.

        Me.SplitContainer1.Panel2.Enabled = False

Kind regards and thanks in advance.

(VB .net 3.5)
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 3 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros