Jan 17, 2006 #1 skhoury IS-IT--Management Nov 28, 2003 386 US Hello all, does anyone know how to make a new item being added to a ListView show up at the top of the list, rather than the bottom? Any leads are much appreciate. Thanks! Sam
Hello all, does anyone know how to make a new item being added to a ListView show up at the top of the list, rather than the bottom? Any leads are much appreciate. Thanks! Sam
Jan 17, 2006 #2 litton1 Technical User Apr 21, 2005 584 GB lstMyList.Items.Insert(0, myString); should do it Age is a consequence of experience Upvote 0 Downvote
Jan 17, 2006 #3 litton1 Technical User Apr 21, 2005 584 GB whoops! try that again with a list view try this link http://www.c-sharpcorner.com/1/ListViewInCSharp.asp Age is a consequence of experience Upvote 0 Downvote
whoops! try that again with a list view try this link http://www.c-sharpcorner.com/1/ListViewInCSharp.asp Age is a consequence of experience
Jan 17, 2006 1 #4 JurkMonkey Programmer Nov 23, 2004 1,731 CA in reality - you need to create an IComparer class and set listview1.ListViewItemSorter = yourIcomparerclass; Look into IComparer and ListViewItemSorter. That should get you somewhere. As an added note: when you set lstview1.ListViewItemSorter, make sure you set it to null first, and then to your comparer. Upvote 0 Downvote
in reality - you need to create an IComparer class and set listview1.ListViewItemSorter = yourIcomparerclass; Look into IComparer and ListViewItemSorter. That should get you somewhere. As an added note: when you set lstview1.ListViewItemSorter, make sure you set it to null first, and then to your comparer.
Jan 18, 2006 #5 chiph Programmer Jun 9, 1999 9,878 US +1 for implementing IComparer. Chip H. ____________________________________________________________________ If you want to get the best response to a question, please read FAQ222-2244 first Upvote 0 Downvote
+1 for implementing IComparer. Chip H. ____________________________________________________________________ If you want to get the best response to a question, please read FAQ222-2244 first
Jan 18, 2006 Thread starter #6 skhoury IS-IT--Management Nov 28, 2003 386 US JunkMonkey - awesome, I'm goign to try it out. Thanks for the tips guys, Sam. Upvote 0 Downvote
Jan 23, 2006 #7 NeilTrain Programmer May 27, 2003 275 US IComparer might be overkill if all he's trying to do is insert at the top. But that's just me. Upvote 0 Downvote
Jan 23, 2006 Thread starter #8 skhoury IS-IT--Management Nov 28, 2003 386 US Neil - is there a more efficent/quicker way to do it other than using an IComparer? Upvote 0 Downvote
Jan 23, 2006 #9 NeilTrain Programmer May 27, 2003 275 US as litton1 pointed out, just insert with an index, such as this: lstMyList.Items.Insert(0, myString); That basically adds the new item as index zero, and bumps the rest down a notch. You only need IComparer if you want to sort the whole list by a particular column Upvote 0 Downvote
as litton1 pointed out, just insert with an index, such as this: lstMyList.Items.Insert(0, myString); That basically adds the new item as index zero, and bumps the rest down a notch. You only need IComparer if you want to sort the whole list by a particular column
Jan 23, 2006 Thread starter #10 skhoury IS-IT--Management Nov 28, 2003 386 US Doh - you're right. And I just tried it and it works like a charm. Fortunatly, I dont need any sorting (at the moment). Thanks, Sam Upvote 0 Downvote
Doh - you're right. And I just tried it and it works like a charm. Fortunatly, I dont need any sorting (at the moment). Thanks, Sam