?
Solved

combo box value changed

Posted on 2004-09-22
1
Medium Priority
?
253 Views
Last Modified: 2010-04-23
I have a function
 Sub FillComboBox(ByVal cbo As ComboBox, ByVal cmd As SqlClient.SqlCommand, ByVal sValueMem As String, ByVal sDisplayMem As String, ByVal CurrentID As Object)
        'Given a combo box, a command string, and a few other parameters, this procedure will fill the combo box with an ID and display value.

        Dim da As New SqlClient.SqlDataAdapter
        Dim ds As New DataSet

        Try
            'Clear all items from the combo box.
            cbo.DataSource = Nothing
            cbo.Items.Clear()

            'Use the local data adapter to fill the local dataset based on the Command object which was passed in.
            ds.Reset()
            da.SelectCommand = cmd
            da.Fill(ds)

            'Set value member, display member.
            'Then populate the combo box from table 0 of the local dataset.
            cbo.DataSource = ds.Tables(0)
            cbo.ValueMember = sValueMem
            cbo.DisplayMember = sDisplayMem

        Catch ex As Exception
            MsgBox("The following error occurred in the FillComboBox procedure with combo box '" & cbo.Name & "':" & vbCrLf & ex.Message)
        End Try
        'If mblnResort = True Then
        '    Exit Sub 'do not set index for resort combo
        'End If
        'Based on the CurrentID, select a value in the combobox
        cbo.SelectedIndex = -1
        If CurrentID Is DBNull.Value Then
            ' Do nothing
        ElseIf CurrentID <> -1 Then
            Try
                cbo.SelectedValue = CurrentID
            Catch ex As Exception
                cbo.SelectedIndex = -1
            End Try
        End If
        ds.Dispose()
        da.Dispose()

    End Sub

which fills every combo box that I have. Now in my form, I have a 4 tabs, where you can have the combobox state in three different tabs. what I want is if the user changes the value in either tab, updates the others.
Thia is what I've been using

Private Sub cmbState_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbState.SelectedIndexChanged
        Try
            cmbState2.Text = cmbState.Text
            cmbState3.Text = cmbState.Text
        Catch ex As Exception
            DisplayError("Combo State changed", ex)
        End Try
    End Sub
0
Comment
Question by:Ilianam
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 5

Accepted Solution

by:
tzxie2000 earned 1000 total points
ID: 12124644
Private Sub cmbState_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbState.SelectedIndexChanged
        Try
            cmbState2.SelectedIndex=cmbState2.Items.IndexOf(cmbState.Text)
            cmbState3.SelectedIndex=cmbState3.Items.IndexOf(cmbState.Text)
        Catch ex As Exception
            DisplayError("Combo State changed", ex)
        End Try
    End Sub
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question