jscix Posted August 4, 2007 Share Posted August 4, 2007 Okay, This code actually works.. but it is Ridiculously slow. (and I know, I know.... Don't use goto.. :/ ) well, For some reason the ListView control isn't enumerable(I've read somewhere you can add in functionality, but I'm still a noob.) Anyway.. I'm wondering if anyone has a better alternative for this, or can help me correct my code, to make it faster. DreamWords is the ListView object. int curind = 0; int cntdw = (DreamWords.Items.Count - 1); int innerind = 0; int Dup = 0; DreamWords.Focus(); while (curind <= cntdw) { cntdw = (DreamWords.Items.Count - 1); DreamWords.Items[curind].Selected = true; string curword1 = DreamWords.SelectedItems[0].Text; curind++; while (innerind <= cntdw) { restart: ; cntdw = (DreamWords.Items.Count - 1); if (innerind > cntdw) { innerind--; goto restart; } DreamWords.Items[innerind].Selected = true; string curword2 = DreamWords.SelectedItems[0].Text; if (curword2.Equals(curword1)) { Dup++; } if (Dup == 2) { DreamWords.SelectedItems[0].Remove(); curind = 0; } innerind++; } Dup = 0; innerind = 0; } Link to comment https://forums.phpfreaks.com/topic/63338-solved-c-removing-duplicate-items-in-a-listview/ Share on other sites More sharing options...
jscix Posted August 7, 2007 Author Share Posted August 7, 2007 Well I Figured it out a couple days ago, forgot about this post. .. if anyones interested or just in case someone else has this problem ever - The solution was to dump the list into an ArrayList Object, which has some awesome functions .. Much Much faster also. http://www.dotnetspider.com/kb/Article17.aspx Link to comment https://forums.phpfreaks.com/topic/63338-solved-c-removing-duplicate-items-in-a-listview/#findComment-317393 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.