Link to home
Create AccountLog in
Avatar of mrafanan
mrafanan

asked on

Copy ComboBOx list to another ComboBox

how can i Copy the first Combo BOx list to another Combo Box in the useform? I am trying to make multiple combo box list with the same list.
Avatar of rgn2121
rgn2121
Flag of United States of America image

Where are the lists coming from?  Your input or reading from a DB?
Any sample code...?
Avatar of mrafanan
mrafanan

ASKER

I have this on one combo box,

Sub addMask()


combobox1.AddItem "A"
combobox1.AddItem "B"
combobox1.AddItem "C)"
combobox1.AddItem "D)"
combobox1.AddItem "E)"
combobox1.AddItem "F"


End Sub


I am making a form, so i would like this to be the same list in the combobox2 without retyping everything.
Avatar of Pratima
<asp:DropDownList ID="DropDownList1" runat="server">
            <asp:ListItem>1</asp:ListItem>
            <asp:ListItem>2</asp:ListItem>
        </asp:DropDownList>
        <asp:DropDownList ID="DropDownList2" runat="server">
        <asp:ListItem>3</asp:ListItem>
            <asp:ListItem>4</asp:ListItem>
        </asp:DropDownList>
        <asp:DropDownList ID="DropDownList3" runat="server">
        </asp:DropDownList>

  foreach ( ListItem item in DropDownList1.Items )
        {
            DropDownList3.Items.Add(item);
        }
        foreach (ListItem item in DropDownList2.Items)
        {
            DropDownList3.Items.Add(item);
        }
Use this....
ComboBox2.List = ComboBox1.List

Open in new window

Sorry, i chose the wrong zone, it should be excel macro.. :(
pratima_mcs - It might pay to read the question, the tags, and the zones it is posted in properly before posting nonsense.
Hi Web, where would i type that? in the userform_Initialize?
ASKER CERTIFIED SOLUTION
Avatar of Wayne Taylor (webtubbs)
Wayne Taylor (webtubbs)
Flag of Australia image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
THANK YOU VERY MUCH!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!