I have 2 listboxes each displaying 2 different lists which are being populated by user input. I was wondering if I could somehow combine the data in each listbox and show it in a third listbox. This is a windowsForms application in visual Studio. I also want to make sure that it is updated properly when a new value is added into the 2 different listboxes. So far what I have done is combined the two lists that I have as so:
public List<String> listAll()
{
List<String> all = new List<string>();
all.AddRange(listFirstName());
all.AddRange(listSecondName());
return all;
}
The problem with this is first of all i dont know if this will update when a new value is added to the other two lists. and secondly now that I have this new list i still dont know how to display it in a listbox. keep in mind that i still need to have the other listboxes containing the first 2 lists displayed in the main form along with this new listbox which will contain the values for both of them.
Cheers, any help is welcome and appreciated.
You can have seperate method to populate listBox3. in that method you can clear existing items and add all the items from listBox1 and listBox3.
when you add items to listBox1 or listBox2 you can call same method after adding items.