have you seen my code?
i think this is what you need ?Code:try this private void btnEnter_Click(object sender,EventArgs e) { if(!string.IsNullOrEmpty(textName.Text.Trim())) { listBox1.Items.Add(textName.Text); textName.Clear(); textName.Focus(); } } private void btnRandomise_Click(object sender,EventArgs e) { Random rnd = new Random(); List<string> randomised = new List<string>(); int cntr = 0; while(cntr != listBox1.Items.Count) { int pos = rnd.Next(1,listBox1.Items.Count + 1); if(!listBox2.Items.Contains(listBox1.Items[pos - 1].ToString()) /*&& !randomised.Contains(listBox1.Text[pos-1].ToString())*/) { listBox2.Items.Add(listBox1.Items[pos - 1]); randomised.Add(listBox1.Items[pos - 1].ToString()); cntr++; } } }




Reply With Quote