0

I have a list boxes List1 and List2 and I want to add selected item from List2 to List1. I do as follows.

List1.Items.Add(List2.SelectedItem);

How to avoid duplicating in List1 if the same item from List2 is being added?

1 Answer 1

1
if (List2.SelectedItem != null 
  if (! List1.Items.Contains(List2.SelectedItem))
     {  List1.Items.Add(List2.SelectedItem);
        List2.Remove(List2.SelectedItem);
     }
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.