how can retrive listbox1 to listbox2 without duplicate value
code for listbox1 to listbox2 move on button clik
Collapse
X
-
Tags: None
-
how can add items listbox1 to listbox2 without duplicate items in c# codes.?
I am use for this codes ,
listbox1 to listbox2 without duplicate add items ,But this codes add items with duplicate entry.
Code:private void button1_Click(object sender, EventArgs e) { int j; for (int i = listBox1.Items.Count - 1; i >= 0; --i ) { j = listBox2.FindStringExact(listBox1.SelectedItem.ToString()); if (j == -1) { listBox2.Items.Add(listBox1.Items[i ]); } else { MessageBox.Show("It fields are already added"); return; }Last edited by tlhintoq; Jan 31 '10, 05:35 PM. Reason: [CODE] ...Your code goes between code tags [/CODE]Comment
-
TIP: When you are writing your question, there is a button on the tool bar that wraps the [code] tags around your copy/pasted code. It helps a bunch. Its the button with a '#' on it. More on tags. They're cool. Check'em out.Comment
-
So you want the item to appear to move from listbox1 to listbox2?
In line 9 you add the item to listbox2
Right after that remove it from listbox1
If the ListBox is new to you, I might suggest you read up on it so you can better understand it. A complete list of its methods along with sample code are available on the MSDN.Code:listBox1.Items.RemoveAt(i);
Comment
Comment