开发者

How to create Object (label, button) using Code

开发者 https://www.devze.com 2023-01-08 00:46 出处:网络
How to cre开发者_Python百科ate Object (label, button) using Code?Dim myButton as new Button myButton.width = 100

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

精彩评论

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