How to create Object (label, button) using Code
How to cre开发者_Python百科ate Object (label, button) using Code?
Dim myButton as new Button
myButton.width = 100
myButton.height = 20
myButton.top = 50
myButton.left = 50
Me.controls.add(myButton)
Dim Label1 as New Label()
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 );
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.
精彩评论