vb.net - Issue selecting only one item with multiple ListBoxes -
vb.net - Issue selecting only one item with multiple ListBoxes -
i'm new vb.net , i've tried create simple application. need create form listboxes , want have 1 item selected @ same time. i've written code in form1 class:
public class form1 private sub aggiornaqki(sender object, e system.eventargs) _ handles listbox1.click, listbox9.click, listbox8.click, listbox7.click, _ listbox6.click, listbox5.click, listbox4.click, listbox3.click, listbox2.click if sender.selectedindex >= 0 if sender.name <> "listbox1" listbox1.selectedindex = -1 if sender.name <> "listbox2" listbox2.selectedindex = -1 if sender.name <> "listbox3" listbox3.selectedindex = -1 if sender.name <> "listbox4" listbox4.selectedindex = -1 if sender.name <> "listbox5" listbox5.selectedindex = -1 if sender.name <> "listbox6" listbox6.selectedindex = -1 if sender.name <> "listbox7" listbox7.selectedindex = -1 if sender.name <> "listbox8" listbox8.selectedindex = -1 if sender.name <> "listbox9" listbox9.selectedindex = -1 end if end sub end class how it's possible have more 1 item selected @ runtime? thing click between listboxes items quickly!
i have no reputation post image can guarantee i've said. i've tried run application on pc same.
i have windows 7 64 bit , .net 4.0.
in new version, i've written console.writeline(sender.name) before first if. when issue occur, seems lastly click event lost because don't find name of lastly listbox clicked!
to confirm this, when 2 items selected, if insert breakpoint , go see value of selecteditem property of listboxes, see 2 of have values <> -1.
the event may want utilize selectedindexchanged. instead of
handles listbox1.click try
handles listbox1.selectedindexchanged, listbox2.selectedindexchanged vb.net
Comments
Post a Comment