1
Answer

move data in between two listboxes without duplicate

Haii i want move data between two listboxes by  using buttons like(<,>,<<,>>)  i want move without duplicate data for  example,in listbox1 have some countries (America,greenland,africa,srilanka...) and listbox2  contains some countries like(germany,pakisthan,nepal,bangladesh,america,srilanka...etc) when i selet listbox1 item for move to listbox2 ,it will compare and move if it is not in listbox2
suppose i select america,it is already in listbox2 so the message will display it already i listbox 2
otherwise it will move listbox2.
Answers (1)
0
Ranjit Powar
NA 8.1k 496.7k 10y
Try this

private void button1_Click(object sender, EventArgs e)
{
  if (listBox2.Items.Contains(listBox1.SelectedItem))
  {
    Response.Write("Already exists");
  return;
  }
  listBox2.Items.Add ( listBox1.SelectedItem);
}




---------------------------------------------------------------------------------------------------
If answer is correct mark it as correct answer.