469,573 Members | 1,678 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,573 developers. It's quick & easy.

Dynamically Creating Controls in windows applications

hi,

iam doing a windows application.i have a requirement like to create labels and textboxes dynamically at runtime.iam giving input as number of labels,and textboxes then it will created dynamically.but here i put this controls in a panel.here my problem is all controls are placed in the same position.
but my requirement is all textboxes are arranged one by one.iam trying with this using tablelayoutpanel.but i dont know how to dynamically create columns,rows in tablelayoutpanel.


please anyone help me with this.

iam new to windows application.
iam using vb.net


my code

Dim inttxtcnt As Integer
inttxtcnt = TextBox4.Text

Dim I As Integer

For I = 1 To inttxtcnt
Dim myTextBox = New TextBox
myTextBox.Text = "Control Number:" & I
panel1.Controls.Add(myTextBox)
Next
Sep 12 '08 #1
1 2116
PRR
750 Expert 512MB
"iam doing a windows application.i have a requirement like to create labels and textboxes dynamically at runtime.iam giving input as number of labels,and textboxes then it will created dynamically.but here i put this controls in a panel.here my problem is all controls are placed in the same position.
but my requirement is all textboxes are arranged one by one.iam trying with this using tablelayoutpanel.but i dont know how to dynamically create columns,rows in tablelayoutpanel.


please anyone help me with this.

iam new to windows application.
iam using vb.net


my code

Dim inttxtcnt As Integer
inttxtcnt = TextBox4.Text

int defLocationX=10;
int defLocationY=10;
Literal lt;


Dim I As Integer

For I = 1 To inttxtcnt
Dim myTextBox = New TextBox
myTextBox.Text = "Control Number:" & I
myTextBox.Location.Y=defLocationY;
myTextBox.Location.X=defLocationX+10;
lt = new Literal();
lt.Text = "<br/>";

panel1.Controls.Add(myTextBox)
panel1.Controls.Add(lt)

Next[/quote]

that should do it ....
Check this too
Sep 12 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

4 posts views Thread by Altramagnus | last post: by
2 posts views Thread by macca | last post: by
6 posts views Thread by Tex | last post: by
9 posts views Thread by netasp | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.