Click here to Skip to main content
15,896,912 members

Comments by Nav-CProject (Top 7 by date)

Nav-CProject 14-Aug-15 3:45am View    
//This works fine.
var nonintersect = listView1.Items.Cast<ListViewItem>().Except(listView2.Items.Cast<ListViewItem>()).Union(listView2.Items.Cast<ListViewItem>().Except(listView1.Items.Cast<ListViewItem>()));
//The Error occurs in the below code
listView3.Items.AddRange(nonintersect.Select(x => x.Clone()).ToArray());

This is what i have so far. @DamithSL
Nav-CProject 14-Aug-15 3:43am View    
Its giving me 2 errors for listView3.Items.AddRange(nonintersect.Select(x=>x.Clone()).ToArray());

Error Message:

Error 1: The best overloaded method match for 'System.Windows.Forms.ListView.ListViewItemCollection.AddRange(System.Windows.Forms.ListViewItem[])' has some invalid argument
Error 2: Argument 1: cannot convert from 'object[]' to 'System.Windows.Forms.ListViewItem[]'
Nav-CProject 14-Aug-15 3:35am View    
Hi i get this error: An unhandled exception of type 'System.ArgumentException' occurred in System.Windows.Forms.dll

Additional information: Cannot add or insert the item '2' in more than one place. You must first remove it from its current location or clone it.

for: listView3.Items.AddRange(nonintersect.ToArray());

@DamithSL
Nav-CProject 14-Aug-15 3:22am View    
Ahh, i see. Thank you. The code you provided me with does not give me an error. How would i now display the unique numbers in listView3? @DamithSL
Nav-CProject 14-Aug-15 3:17am View    
Error Message: 'System.Windows.Forms.ListView.ListViewItemCollection' does not contain a definition for 'Except' and no extension method 'Except' accepting a first argument of type 'System.Windows.Forms.ListView.ListViewItemCollection' could be found (are you missing a using directive or an assembly reference?) @DamithSL