create labels and textboxes at runtime

  • 11 years ago

    I want to create a label and a textbox for each item in a list at runtime. (control array)

    is it also possisible to put the listitems data into the corresponding label/textbox 's tag



  • 11 years ago

    I worked it out, here is the code I used.

    Adodc1.Enabled = True
    Adodc1.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\products.mdb"
    Adodc1.RecordSource = "select InputName from IN" & Combo1.Text
    Set DataGrid1.DataSource = Adodc1

    Label2(0).Caption = DataGrid1.Text
    For x = 1 To DataGrid1.ApproxCount
    Load Label2(x)
    Label2(x).Top = Label2(x - 1).Top + 400
    Label2(x).Visible = True
    DataGrid1.Row = x - 1
    Label2(x).Caption = DataGrid1.Text & ":"

    Load Text1(x)
    Text1(x).Top = Text1(x - 1).Top + 400
    Text1(x).Visible = True
    Text1(x).Tag = DataGrid1.Text

    Next x

Post a reply

Enter your message below

Sign in or Join us (it's free).


Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“There are 10 types of people in the world, those who can read binary, and those who can't.”