0

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'

3
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by bilal_fazlani
0
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
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.