please i need help here. i want write code for label control into my application. i wrote the code below, but was not getting the labels when i run the program.

GroupBox.Controls.Clear()
        Dim lbl1 As Label = New Label()
        lbl1.AutoSize = True
        lbl1.BackColor = System.Drawing.SystemColors.Control
        lbl1.Font = New Font(lbl1.Font.FontFamily, 20)
        lbl1.ForeColor = System.Drawing.Color.White
        lbl1.Location = New System.Drawing.Point(419, 134)
        lbl1.Name = "label1"
        lbl1.Size = New System.Drawing.Size(65, 23)
        lbl1.TabIndex = 4
        lbl1.Text = " Hello World!!"
        Dim lbl2 As Label = New Label()
        lbl2.AutoSize = True
        lbl2.BackColor = System.Drawing.SystemColors.Control
        lbl2.Font = New Font(lbl1.Font.FontFamily, 20)
        lbl2.ForeColor = System.Drawing.Color.White
        lbl2.Location = New System.Drawing.Point(419, 134)
        lbl2.Name = "label2"
        lbl2.Size = New System.Drawing.Size(65, 23)
        lbl2.TabIndex = 4
        lbl2.Text = " Welcome to vb!"
        GroupBox2.Controls.Add(lbl2)

Recommended Answers

All 4 Replies

You forget to add lbl1 to groupbox

GroupBox2.Controls.Add(lbl1)

and every thing is fine in your code just hide the location of you the label may be because of that label is not visible to you but the control is added to groupbox.

If you get any problem feel free to ask.

addontext += "<div>" + objSal_PropertyFolioPageProp.Address.ToString() + "</div>";

this is my code its display only address
how i can add the lable in this code

You have a GroupBox(line 1) and GroupBox2( line 22) are they added to the Controls collection of the Form?

Hey dude,
Sorry to say but your code is working fine.
I just change the Location of label as on my form it exceed the location and as for "lbl1" you forgot to add the control.

Not Believe: Download the Attachment
I have change some more things.
you should watch it

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.