views:

8

answers:

1

I'm just a beginner at VB.NET... I want to be able to insert a combobox control onto my form through code but I'm not sure how. Google doesn't seem to answer.

Something along the lines of (I have no idea) Me.AddControl("Combobox")

I would obviously then need to set the properties to setup the position/size etc.

Thanks

A: 

In its simplest form:

Dim cbo As New ComboBox()
' set Location and whatever else is needed '
cbo.Visible = true
Me.Controls.Add(cbo)

If you don't want the ComboBox directly inside the Form, but perhaps inside a Panel control, you just need to replace Me with a variable referring the intented parent control:

Panel1.Controls.Add(cbo)
Fredrik Mörk