how to load the combo box'values from one form to another form's combobox

Example:

form1:
cust(table name)
no(textbox)
name(combobox)
form2:
CName(combobox)

now i load the form1's name which is the combo values .. to form 2's combo box whixh is name of 'CName'

Recommended Answers

How your loading the combobox in form 1? are u using dataset?

Jump to Post

All 2 Replies

How your loading the combobox in form 1? are u using dataset?

Dim mysqlcon As New SqlConnection("data source=bilal-pc\sqlexpress;initial catalog =erp;integrated security=true")
        mysqlcon.Open()
        Dim mysqlcom As New SqlCommand("select fname from customers", mysqlcon)
        Dim mysqlrdr As SqlDataReader
        mysqlrdr = mysqlcom.ExecuteReader

        While mysqlrdr.Read

            ComboBox1.Items.Add(mysqlrdr(0).ToString)
            myform2.ComboBox2.Items.Add(mysqlrdr(0).ToString)

            'just make sure that myform.combobox2 is public and not private
'or if u want to copy existing items from 1 combo box to another combobox

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

        ComboBox2.Items.Clear()

        For Each i As String In ComboBox1.Items

            form2.ComboBox2.Items.Add(i.ToString)
            'just make sure that myform.combobox2 is public and not private
        Next
Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.