lapucca
asked on
Why my ListView Control is not sorted after I added items to it?
This Listview control (NodeDetail) is selected to sort Ascending in the designer. I added some items to the list using code below when the form is loaded but the listing is not softed at all. How can I get it to sort? Thanks.
NodeDetail.Items.Add(new ListViewItem(new string[] { "Successful Kerberos Activity Report",
"Display successful kerberos activity information." }, 9));
NodeDetail.Items.Add(new ListViewItem(new string[] { "Failed Kerberos Activity Report",
"Display failed Kerberos Activity information." }, 9));
NodeDetail.Items.Add(new ListViewItem(new string[] { "All Kerberos Activity Report",
"Display all Kerberos Activity information." }, 9));
NodeDetail.Sort();
NodeDetail.Refresh();
NodeDetail.Items.Add(new ListViewItem(new string[] { "Successful Kerberos Activity Report",
"Display successful kerberos activity information." }, 9));
NodeDetail.Items.Add(new ListViewItem(new string[] { "Failed Kerberos Activity Report",
"Display failed Kerberos Activity information." }, 9));
NodeDetail.Items.Add(new ListViewItem(new string[] { "All Kerberos Activity Report",
"Display all Kerberos Activity information." }, 9));
NodeDetail.Sort();
NodeDetail.Refresh();
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
lapucca
I tried your code in VS and it works ok.
Can you send more code, so we'll be able to check more?
Thanks.
I tried your code in VS and it works ok.
Can you send more code, so we'll be able to check more?
Thanks.
ASKER
You're right. I need to add the following in my code then it worked. Thanks.
this.NodeDetail.Sorting = System.Windows.Forms.SortO rder.Ascen ding;
this.NodeDetail.Sorting = System.Windows.Forms.SortO
ASKER
this.NodeDetail.Sorting = System.Windows.Forms.SortO