2017-08-01 43 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); 
    }