i have problem combobox2 every time choose item picture wont load, want every selected item in combobox1 items in combobox2 change, , every selected item in combobox2 different picture load.
if combobox1.selectedindex = 0 picturebox1.image = nothing combobox2.items.clear() combobox2.text = "choose car" combobox2.items.add("car1") combobox2.items.add("car2") combobox2.items.add("car3") if combobox2.selecteditem = "car1" picturebox1.image = my.resources.bmw end if elseif combobox1.selectedindex = 1 picturebox1.image = nothing combobox2.items.clear() combobox2.text = "choose truck" combobox2.items.add("truck1") combobox2.items.add("truck2") combobox2.items.add("truck3") if combobox2.selecteditem = "truck1" picturebox1.image = my.resources.truck end if elseif combobox1.selectedindex = 2 picturebox1.image = nothing combobox2.items.clear() combobox2.text = "choose bike" combobox2.items.add("bike1") combobox2.items.add("bike2") combobox2.items.add("bike3") if combobox2.selecteditem = "bike1" picturebox1.image = my.resources.bike end if end if
what's wrong code when checking selected items in combobox1, add new items combobox2 @ same time check selected items in combobox2. means, not time select in combobox2. inevitably throw exception since nothing selected.
so respond combobox1 selection changed events , add new items combobox2 accordingly , in separate event handling sub, load pictures picturebox according selection in combobox2. code work -
private sub combobox1_selectedindexchanged(sender object, e eventargs) handles combobox1.selectedindexchanged if combobox1.selectedindex = 0 picturebox1.image = nothing combobox2.items.clear() combobox2.text = "choose car" combobox2.items.add("car1") combobox2.items.add("car2") combobox2.items.add("car3") elseif combobox1.selectedindex = 1 picturebox1.image = nothing combobox2.items.clear() combobox2.text = "choose truck" combobox2.items.add("truck1") combobox2.items.add("truck2") combobox2.items.add("truck3") elseif combobox1.selectedindex = 2 picturebox1.image = nothing combobox2.items.clear() combobox2.text = "choose bike" combobox2.items.add("bike1") combobox2.items.add("bike2") combobox2.items.add("bike3") end if end sub private sub combobox2_selectedindexchanged(sender object, e eventargs) handles combobox2.selectedindexchanged if combobox2.selecteditem = "car1" picturebox1.image = my.resources.bmw end if if combobox2.selecteditem = "truck1" picturebox1.image = my.resources.truck end if if combobox2.selecteditem = "bike1" picturebox1.image = my.resources.bike end if end sub
Comments
Post a Comment