remove items from Listbox
-
I have 2 listboxs. 1st one is data bound and secound one is populated by selecting 1st. eg: listbox1 jenny rock when i click listbox 1 items it also appear in listbox2. now when i click listbox1 item 2 things happen: 1. listbox2 populates with same item selected in listbox1. 2. a textbox which gets valueid from listbox1 item select. So now, when i try to remove item from listbox2 then itm should be removed from the list and the valueid in textbox related to the item should also be removed. I have tried o do this by selecteditem property of listbox but it didn't work. since listbox1 is data bound but listbox2 is not.
-
I have 2 listboxs. 1st one is data bound and secound one is populated by selecting 1st. eg: listbox1 jenny rock when i click listbox 1 items it also appear in listbox2. now when i click listbox1 item 2 things happen: 1. listbox2 populates with same item selected in listbox1. 2. a textbox which gets valueid from listbox1 item select. So now, when i try to remove item from listbox2 then itm should be removed from the list and the valueid in textbox related to the item should also be removed. I have tried o do this by selecteditem property of listbox but it didn't work. since listbox1 is data bound but listbox2 is not.
-
ok, but what about valueid which is populated when i add items in lstbox2 from listbox1. i have a button "ADD". when i select item in listbox1 and click add button item is added to listbox2 and so as its valueid in textbox. but when i click on remove button the item will get removed from listbox2 but valuid for that item is removed from textbox. This is because listbox2 is not databound and valueid is generated from listbox1.
-
ok, but what about valueid which is populated when i add items in lstbox2 from listbox1. i have a button "ADD". when i select item in listbox1 and click add button item is added to listbox2 and so as its valueid in textbox. but when i click on remove button the item will get removed from listbox2 but valuid for that item is removed from textbox. This is because listbox2 is not databound and valueid is generated from listbox1.
scottichrosaviakosmos wrote:
and valueid is generated from listbox1.
At what time? Easiest solution would be to call that generate-routine again, otherwise you'd have to manually cut it from the string, before deleting the item.
Bastard Programmer from Hell :suss: if you can't read my code, try converting it here[^]
-
scottichrosaviakosmos wrote:
and valueid is generated from listbox1.
At what time? Easiest solution would be to call that generate-routine again, otherwise you'd have to manually cut it from the string, before deleting the item.
Bastard Programmer from Hell :suss: if you can't read my code, try converting it here[^]
Ok, let me explain in details. I have a form which has 2 listboxs, textbox and 2 buttons. lst1 and lst2. Also has 2 buttons "add" and "Remove". lst1 is populated from a database table which has 2 fields : "Name" ad "emailid". lst1 will show items "name" from table column "name". eg: ronny, danial... when i select an item(name) in lst1 and click Add button then the name will be added in lst2(lst2 is not connected to datasource). Also the displayvalue member or emailid with respect to the name selected in lst1 will be added to the textbox.(this is working fine). Now, when i select an item in lst2 which was added from lst1 and then click on Remove button then the item(name) should be removed from lst2(this is also working fine) and also the emailid corresponding to the value(name) selected in lst2 should be removed from textbox. emailid on selectitem of lst2 is not getting removes since the lst2 is connected to database. lst is adding its item from lst1. I hope now the scenario is clear.!:| Cheers
-
Ok, let me explain in details. I have a form which has 2 listboxs, textbox and 2 buttons. lst1 and lst2. Also has 2 buttons "add" and "Remove". lst1 is populated from a database table which has 2 fields : "Name" ad "emailid". lst1 will show items "name" from table column "name". eg: ronny, danial... when i select an item(name) in lst1 and click Add button then the name will be added in lst2(lst2 is not connected to datasource). Also the displayvalue member or emailid with respect to the name selected in lst1 will be added to the textbox.(this is working fine). Now, when i select an item in lst2 which was added from lst1 and then click on Remove button then the item(name) should be removed from lst2(this is also working fine) and also the emailid corresponding to the value(name) selected in lst2 should be removed from textbox. emailid on selectitem of lst2 is not getting removes since the lst2 is connected to database. lst is adding its item from lst1. I hope now the scenario is clear.!:| Cheers
scottichrosaviakosmos wrote:
Now, when i select an item in lst2 which was added from lst1 and then click on Remove button then the item(name) should be removed from lst2(this is also working fine) and also the emailid corresponding to the value(name) selected in lst2 should be removed from textbox.
So, everything is working fine, except for the removal of the email-address in the textbox?
Bastard Programmer from Hell :suss: if you can't read my code, try converting it here[^]
-
scottichrosaviakosmos wrote:
Now, when i select an item in lst2 which was added from lst1 and then click on Remove button then the item(name) should be removed from lst2(this is also working fine) and also the emailid corresponding to the value(name) selected in lst2 should be removed from textbox.
So, everything is working fine, except for the removal of the email-address in the textbox?
Bastard Programmer from Hell :suss: if you can't read my code, try converting it here[^]
yes.
-
yes.
..and the email-address needs to be removed from the textbox, if the "remove" button is clicked? Emailaddresses are unique, so you could try and replace that part of the textbox with an empty string, like so;
textBox1.Text = textBox1.Text.Replace("et@home.nl", "");
Bastard Programmer from Hell :suss: if you can't read my code, try converting it here[^]