c# ListView sorting problem

I have a ListView which I can sort by clicking the columns. This works just fine. But I have a method which deletes a listview item and adds it again. After this the item is at the bottom and not at the same position as befor. I want it where it was. I tried it with lsvListView.Sort(); but its allways at the bottom..

I sort the columns with the ListViewColumnSorter class from Microsoft..
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Guy Hengel [angelIII / a3]Billing EngineerCommented:
>. This works just fine.
can you show it?

for the reference:

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
socom1985Author Commented:
I'm sure I'm not getting something..
I have it like in the link for the columns clicks and it works..
but when I add a new list item it should automatically sort after the last sorting criteria..
private ListViewColumnSorter lvwColumnSorter;
this.lstvReports.ListViewItemSorter = lvwColumnSorter;
//Lists for faster filtering
lstvicOnlyErrors = new ListViewGroup();
lstvicAllReports = new ListViewGroup();

Open in new window

socom1985Author Commented:
I think I found the problem. When I click the standard column twice to sort it again then it works...
Just have to find out how to do it without that..
Angular Fundamentals

Learn the fundamentals of Angular 2, a JavaScript framework for developing dynamic single page applications.

socom1985Author Commented:
Somehow the lstvListview.Sort(); method doesn't know the standard sorting.. so when I start the app and I remove and add the ListviewItem it doesn't work. But when I first click a column to sort it, then it works.. Anybody know where to set this?
Guy Hengel [angelIII / a3]Billing EngineerCommented:
adding a item adds at the end, it does not "sort" automatically at the place according to the sorting.
so, after adding a new item, you have to sort explicitly once according to the sort you want.
socom1985Author Commented:
I just did

            //Standart sort = Column 1
            lvwColumnSorter.SortColumn = 1;
            lvwColumnSorter.Order = SortOrder.Descending;

in the constructor
Guy Hengel [angelIII / a3]Billing EngineerCommented:
that does not sort implicitly.
as I said, after each new insert (or bulk of inserts), you need to call the sort() method explicitly.
socom1985Author Commented:
no It works now because I insert the whole ListViewItemGroup new...
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.