2017-08-01 45 views

回答

0

很简单:

foreach (var item in listBox1.Items) 
    listBox2.Items.Remove(item); 

希望对大家有所帮助:)

+0

根据问题,您已将列表框向后移动。 – itsme86

0

这应做到:

foreach(var item in listBox1.Items) 
    { 
     // check if listbox2 contains the current item in the foreach loop. 
     // don't forget to use: using System.Linq; 
     bool hasItem = listBox2.Items.Contains(item); 


     // if it has it than remove it 
     if(hasItem) 
      listBox2.Items.Remove(item); 
    }