I am generating comboboxes as:
Public Combos() As ComboBox
later I use:
ReDim Combos(5)
For J = 0 To 5
Combos(J) = New ComboBox
Next
I use Combos(0).Items.Add(Item) for example to populate them.
However I cannot display the comboboxes on the form.
What is missing?
.NET Programming
Last Comment
hlominac
8/22/2022 - Mon
Dirk Haest
You still need to place them somewhere on the form (through coding)
Example:
For J = 0 To 5
ComboBox x = New ComboBox
x.Size = New System.Drawing.Size(60, 15)
x.Location = New System.Drawing.Point(30 * J, 200)
Me.Controls.Add(x)
Combos(J) = x
Next
Dhaest:,
When I ran your code I got an error message at: Me.Controls.Add(x)
Controls is not a member of MyProgram.Data where Data is the subroutine containing the code.
How do I declare Controls?
Harold
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
Example:
For J = 0 To 5
ComboBox x = New ComboBox
x.Size = New System.Drawing.Size(60, 15)
x.Location = New System.Drawing.Point(30 * J, 200)
Me.Controls.Add(x)
Combos(J) = x
Next
http://www.dreamincode.net/forums/topic/63445-dynamic-form-and-controls-generation/