Dynamically Creating Controls in windows applications

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bharathi228
    New Member
    • Jul 2008
    • 28

    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 tablelayoutpane l.but i dont know how to dynamically create columns,rows in tablelayoutpane l.


    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
  • PRR
    Recognized Expert Contributor
    • Dec 2007
    • 750

    #2
    "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 tablelayoutpane l.but i dont know how to dynamically create columns,rows in tablelayoutpane l.


    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.Locat ion.Y=defLocati onY;
    myTextBox.Locat ion.X=defLocati onX+10;
    lt = new Literal();
    lt.Text = "<br/>";

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

    Next[/QUOTE]

    that should do it ....
    Check this too

    Comment

    Working...