|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
listboxes to select/deselect multiple itemsListbox1/Textbox1 contains list of all items not selected item A item B item D Listbox2//Textbox2 contains list of all items selected item C item E User then can highlight desired items to select/deselect using the corresponding arrows (or the like). Any sample/tip is greatly appreciated. Bill There are usually several ways, here is one which uses the
SelectedIndexChamnged Event of the source Listbox. In my Example, I have named them lb1 and lb2 ( source and destination respectively ) Private Sub lb1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lb1.SelectedIndexChanged Dim o As Object Dim senderBox As ListBox senderBox = DirectCast(sender, ListBox) lb2.Items.Clear() For Each o In senderBox.SelectedItems lb2.Items.Add(o) Next End Sub - Terry Burns http://TrainingOn.net Show quoteHide quote "Bill Nguyen" <billn_nospam_please@jaco.com> wrote in message news:%23MeB0BIMFHA.568@TK2MSFTNGP09.phx.gbl... >I would like to be able to do the following: > > Listbox1/Textbox1 contains list of all items not selected > > item A > item B > item D > > Listbox2//Textbox2 contains list of all items selected > > item C > item E > > User then can highlight desired items to select/deselect using the > corresponding arrows (or the like). > > Any sample/tip is greatly appreciated. > > Bill > Terry;
I would like to remove the selected items from senderBox once they moved to lb2 in your example. I can seem to make it work I tried to use ..Items.Remove(.selectedindex) but the items remain in the senderBox. Please help! Thanks Bill Show quoteHide quote "Terry Burns" <u*@ourWebSite.com> wrote in message news:%23%23ZA1EJMFHA.3420@tk2msftngp13.phx.gbl... > There are usually several ways, here is one which uses the > SelectedIndexChamnged Event of the source Listbox. In my Example, I have > named them lb1 and lb2 ( source and destination respectively ) > > Private Sub lb1_SelectedIndexChanged(ByVal sender As System.Object, ByVal > e As System.EventArgs) Handles lb1.SelectedIndexChanged > > Dim o As Object > > Dim senderBox As ListBox > > senderBox = DirectCast(sender, ListBox) > > lb2.Items.Clear() > > For Each o In senderBox.SelectedItems > > lb2.Items.Add(o) > > Next > > End Sub > > - > Terry Burns > http://TrainingOn.net > > > > > > > "Bill Nguyen" <billn_nospam_please@jaco.com> wrote in message > news:%23MeB0BIMFHA.568@TK2MSFTNGP09.phx.gbl... >>I would like to be able to do the following: >> >> Listbox1/Textbox1 contains list of all items not selected >> >> item A >> item B >> item D >> >> Listbox2//Textbox2 contains list of all items selected >> >> item C >> item E >> >> User then can highlight desired items to select/deselect using the >> corresponding arrows (or the like). >> >> Any sample/tip is greatly appreciated. >> >> Bill >> > >
Please do NOT sign the VB.COM petition
What am I doing wrong - Trying to update Option Strict disallows late binding, need to update code How to create a Serialnumber for App programmatically? Visual Basic App Memory Issue Passing objects ByVal vs ByRef Invert an Arraylist.Sort() SharpZipLib VBN2002 - Programmatically creating a form using a string value as name Parsing a fixed length record into fields |
|||||||||||||||||||||||