Click here to Skip to main content
15,893,588 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Have several fields on windows form which inplement with comboboxes. I porpulate these comboboxes with datatble. The code is shown below. Everything works fine but there is one problem.

VB
Public Sub getFamilyRel(cb As ComboBox)
        Try
            Dim CMD As New SqlClient.SqlCommand
            Dim dt As New DataTable
            CMD.CommandText = "select Code, code + ' - ' + description as Des from famrelup"
            CMD.CommandType = CommandType.Text
            Dim CN As New SqlClient.SqlConnection(My.Settings.cdataConnectionString.ToUpper)
            CMD.Connection = CN
            CN.Open()
            Dim RDR As New SqlClient.SqlDataAdapter
            RDR.SelectCommand = CMD
            RDR.Fill(dt)
            With cb
                .DataSource = dt
                .ValueMember = "code"
                .DisplayMember = "des"
            End With
        Catch ex As Exception
            MessageBox.Show(ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error)
        End Try
    End Sub


The problem is that I update the base tables that populate the comboboxes via modal forms and these updates do not show up in the comboboxes unless I reload the form which contains the comboboxes.

I wonder if anybody can help me to have the updates show up in the comboboxes lists without reloading the form.

I am using .NET 2012

Thanks for usual assistance
Posted
Updated 2-May-14 11:11am
v2
Comments
Richard C Bishop 2-May-14 17:32pm    
Can you use an updatepanel for them?
noblepaulaziz 2-May-14 17:51pm    
Sure
DamithSL 3-May-14 2:14am    
how you open modal forms? can you update the question with related code?
noblepaulaziz 3-May-14 17:43pm    
I use the ShowDialog() method of Windows Form.

Yes, I am able to update the underlying table via this dialog form but the inserted record does not show up in the combobox of the parent form unless I reload the parent form.

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