Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

combo box value changed

Posted on 2004-09-22
1
Medium Priority
?
256 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

618 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