vb.net - Searching different array depending on Listbox selection -


first, here code:

public class form1     'training     dim pabumon() string = {"motimon", "yokomon", "tanemon"}      private sub training1_selectedindexchanged_1(sender system.object, e system.eventargs) handles training1.selectedindexchanged         dim arrayname string = training1.selecteditem         dim highsub integer = 0         training2.items.clear()          each evo string in arrayname              training2.items.add(arrayname(highsub))             highsub += 1          next evo     end sub end class 

my goal populate listbox2 array. want populate array same name selected item in listbox1. of now, spell out text of selected index in listbox1. want add items motimon, yokomon, , tanemon listbox2 when select pabumon listbox1.

try this. way, add more items training1 list, can add new list listboxitems shown in form1_load

listboxitems list of items add training2. first item in each list name of list add training1

public class form1      dim listboxitems new list(of string()) 

here add lists listboxitems , add first item in lists training1

    private sub form1_load(sender object, e eventargs) handles me.load         listboxitems.add({"pabumon", "motimon", "yokomon", "tanemon"})         listboxitems.add({"list2", "cat", "dog", "pig"})         listboxitems.add({"list3", "cow", "chicken", "horse"})         populatetraining1()     end sub 

this goes through each list in listboxitems add first item training1

    private sub populatetraining1()         each item string() in listboxitems             training1.items.add(item(0))         next     end sub 

this clear training2, search through listboxitems until finds match listname , populate training2 rest of items found in list.

    private sub populatetraining2(listname string)         training2.items.clear()         dim templist new list(of string)         each training2list string() in listboxitems             if training2list(0) = listname                 listitems integer = 1 training2list.count - 1                     training2.items.add(training2list(listitems))                 next             end if         next     end sub 

this accomplishes same original code using new data

    private sub training1_selectedindexchanged_1(sender system.object, e system.eventargs) handles training1.selectedindexchanged         dim highsub integer         populatetraining2(training1.selecteditem.tostring)         highsub = training2.items.count     end sub  end class 

Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -