开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜