Reputation: 5648
How to create Object (label, button) using Code?
Upvotes: 0
Views: 6499
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
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
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