Click here to Skip to main content
15,884,176 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
:-D

I having a bit of a problem.:confused:
I would like to know how to add or remove a combo box in a program. For example, I would like the user to add or remove a combo box as an option. Similarly, removing or adding Multiple toolbars.

I was thinking of having a set amount of hidden combo-boxes so the user can either make them visible or not visible to create a sense of adding or removing the combo-boxes. :doh:

However, i would like to simply randomized a series of combo-boxes by the click of a button or otherwise in a problem because i do see it happens in web but for software i would like to know how to do it.

:sigh:
Posted

You can dynamically add comboboxes at runtime by declaring a new combobox, setting it's parent property to the container (i.e - panel, groupbox etc), then setting it's position and setting visible to true.

In VB.Net
VB
Private intTop As Integer = 5

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Dim cboBox As New ComboBox
        cboBox.Parent = Me
        cboBox.Top = intTop
        intTop += 5 + cboBox.Height
        cboBox.Visible = True

    End Sub

Hope this helps
 
Share this answer
 
You are surely not using VB6, C++, C#, and VB.NET ? Tag your questions properly.

In C# and VB.NET you can add them to the controls collection to your hearts content. In C++ you can create them and position them on a form. I have no idea in VB6.
 
Share this answer
 
if you are using vb6 please try this
VB
private sub form_load()
cmb1.visible:true
cmb2.visible:false
cmb3.visible:false
end sub
private sub cmd_click()
cmb2.visible:true
cmb3.visible:true
end sub

this would display only one combo box when the form is loaded....and display all combo boxes when the button is clicked
 
Share this answer
 
v2
Comments
fjdiewornncalwe 19-Dec-11 16:36pm    
This question is 21 months old and it already had accepted answers. It didn't need this answer.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900