dcsimg
Results 1 to 2 of 2

Thread: Storing List of images to variable based of Comb/Listbox selection

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2014
    Posts
    10

    Storing List of images to variable based of Comb/Listbox selection

    Hey guys.

    I'm writing a program to display a list of images using two forms. On Form1 a combobox and listbox are displayed. The user selects the desired option in the combobox and the listbox populates based on the specific selection from the combo box. Code below:
    Code:
     Public Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
    
            ListBox1.Items.Clear()
            Select Case ComboBox1.Text
    
                Case "Pre-Training"
                    ListBox1.Items.Add("Baseline Block 1")
                    ListBox1.Items.Add("Baseline Block 2")
                    ListBox1.Items.Add("Baseline Block 3")
                    ListBox1.Items.Add("Symmetry Block 1")
                    ListBox1.Items.Add("Symmetry Block 2")
                    ListBox1.Items.Add("Symmetry Block 3")
                    ListBox1.Items.Add("Transitivity Block 1")
                    ListBox1.Items.Add("Transitivity Block 2")
                    ListBox1.Items.Add("Transitivity Block 3")
    
                Case "Baseline"
    
                    ListBox1.Items.Add("Block 1")
                    ListBox1.Items.Add("Block 2")
                    ListBox1.Items.Add("Block 3")
                    ListBox1.Items.Add("Block 4")
                    ListBox1.Items.Add("Block 5")
                    ListBox1.Items.Add("Block 6")
                    ListBox1.Items.Add("Block 7")
    
                Case "Symmetry"
                    ListBox1.Items.Add("Block 1")
                    ListBox1.Items.Add("Block 2")
                    ListBox1.Items.Add("Block 3")
                    ListBox1.Items.Add("Block 4")
                    ListBox1.Items.Add("Block 5")
    
                Case "Transitivity"
                    ListBox1.Items.Add("Block 1")
                    ListBox1.Items.Add("Block 2")
                    ListBox1.Items.Add("Block 3")
                    ListBox1.Items.Add("Block 4")
                    ListBox1.Items.Add("Block 5")
    
            End Select
    
    
    
        End Sub
    Each selection, for example, Pre-Training-Baseline Block 1 would be associated with a specific list; Pre-training-Baseline Block2 with a different list; Transitivity-Block 1 with a different list; and so on (So about 26 lists of images in total).

    This function displays correctly. However my main issue, trying to associate the selections in the combo box & listbox with the specific lists of images. How could I do this? Here is an example of one the lists I have:

    Code:
    Public Shared PTB1 As New List(Of Image) From {My.Resources.orange, My.Resources.banana,
                                             My.Resources.cat, My.Resources.hammer,
                                             My.Resources.apple, My.Resources.Screw,
                                             My.Resources.cat, My.Resources.pig,
                                             My.Resources.Tapemeasure, My.Resources.hammer,
                                             My.Resources.orange, My.Resources.pig,
                                             My.Resources.apple, My.Resources.Screw,
                                             My.Resources.hammer, My.Resources.Screw,
                                             My.Resources.cat, My.Resources.banana,
                                             My.Resources.pig, My.Resources.elephant,
                                             My.Resources.apple, My.Resources.banana,
                                             My.Resources.hammer, My.Resources.elephant}
    My coding knowledge is fairly limited so the only way I could think of trying to accomplish this would be very time consuming and way too lengthy (setting up variables for the comb and listbox selections and doing a bunch of if then statements etc.).

    Thank you for the help guys. I think this is my last hurdle to finishing this all up.

  2. #2
    I don't do your homework! opus's Avatar
    Join Date
    Jun 2000
    Location
    Good Old Europe
    Posts
    3,863

    Re: Storing List of images to variable based of Comb/Listbox selection

    As far as I understand you different lists of images for each posible selection of combobox and listbox. Since the listbox gets only filled after the combobox selection you could select the correct list of images when an item in the listbox is selected. Since the selection is based on combobox and listbox there is no way around some ifs.
    You're welcome to rate this post!
    If your problem is solved, please use the Mark thread as resolved button


    Wait, I'm too old to hurry!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width