cdxf
cdxf

Reputation: 5648

How to create Object (label, button) using Code

How to create Object (label, button) using Code?

Upvotes: 0

Views: 6499

Answers (4)

Tobiasopdenbrouw
Tobiasopdenbrouw

Reputation: 14039

Edit: this answer posted before clarification in the original question.

Try information pages such as HOW TO: Dynamically Create Controls in ASP.NET with Visual Basic .NET. But really: also get a book and study this stuff.

Upvotes: 0

tanascius
tanascius

Reputation: 53944

You create you Label like every other object, set the properties you need and add it to the Controls collection of your form or usercontrol.
I have only a C# example here:

var label = new Label
{
    BackColor = Color.DarkGray,
    TextAlign = ContentAlignment.MiddleCenter,
    Width = 60,
};
label.MouseClick += LabelOnMouseClick;

Controls.Add( label );

Upvotes: 1

Ash Burlaczenko
Ash Burlaczenko

Reputation: 25465

Dim myButton as new Button  
myButton.width = 100  
myButton.height = 20  
myButton.top = 50  
myButton.left = 50  
Me.controls.add(myButton)  

Upvotes: 2

Henk Holterman
Henk Holterman

Reputation: 273274

  Dim Label1 as New Label()

Upvotes: 1

Related Questions