combo box help

  • 15 years ago
    so what im trying to do is load anther form called frmPacific when a user chooses pacific_instruments from a combo box

    So what i have is a combo box on the main page, the drop down items of the combo box is as follows  Pacific_Instruments, Daytronics, Kinetics, etc
    each choice eventually will have its own windows that the user must config. But I don’t know how to code so that different windows show/load upon the choice the user takes. Any help would be greatly appreciated, thank you.
  • 15 years ago
    Code:

       Private Sub cmbMyComboBox_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbMyComboBox.SelectedIndexChanged
           Select Case cmbMyComboBox.SelectedIndex
               Case 0 'Pacific_Instruments
                   'Create a new instance of the Pacific_Instruments form

               Case 1 'Daytronics
                   'Create a new instance of the Daytronics form

               Case 2 'Kinetics
                   'Create a new instance of the Kinetics form
           End Select
       End Sub

    u need to use the SelectedIndexChanged event of the combo box which is fired everytime a new item is selected.  within this event u select case on the SelectedIndex of the combobox.

    if u dont want the form to open right when it is selected in the combobox (ie u want to wait until an "OK" button is pressed) u can copy and paste the select case code and put it in the buttons click event.
  • 15 years ago

    I would strongly suggest using a Button to open the form, as Nimpo mentioned, rather than opening it when the selection is made.  Some people like to scroll through the choices in a ComboBox using the up and down arrow keys.  In this case the SelectedIndexChanged event will be raised multiple times but they would not want every window opened.

  • 15 years ago

    hey it worked, thanks for all the input

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“I have always wished for my computer to be as easy to use as my telephone; my wish has come true because I can no longer figure out how to use my telephone” - Bjarne Stroustrup