• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 273
  • Last Modified:

Sorting ListView Items

Hi there

I hava a form that contains a list view that hase 4 columns of string each thier names are wit their indicies:

0- Has Nothing but I added it for allignment thing

1- Variable name

2- Arabic Value

3- English Value

and I want to sort that listview Items acording to Variable name

any one to tell me how to do it

thanks in advance
0
mohammadalsayeh
Asked:
mohammadalsayeh
  • 4
  • 2
1 Solution
 
Bob LearnedCommented:
You should be able to use a Comparer class to sort the ListView:

Here is an example of implementing a custom Comparer class:

Make a ListView control sort using the column you click in VB .NET
http://vb-helper.com/howto_net_listview_sort_clicked_column.html

Bob
0
 
mohammadalsayehAuthor Commented:
but I want to sort it before I display it on a listview


0
 
Bob LearnedCommented:
What are you displaying?  Where are you getting the data to display in the ListView?

Bob
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
Solar_FlareCommented:
if you are querying it from a database then you can add "ORDER BY Variable_name" to the end of the query to sort it.
0
 
mohammadalsayehAuthor Commented:
I`m getting it from an xml file by Dataset

I did put it in a default view and sorted it by using the sort property but it didn`t work

0
 
Bob LearnedCommented:
How did you try to sort the DefaultView, and why didn't it work?

   table.DefaultView.Sort = "Variable DESC"

Bob
0
 
Bob LearnedCommented:
After applying a sort to the DefaultView, where you trying to get the values from the table or the DataView:

   For Each row As DataRow In table.Rows

        or

   For Each row As DataRowView in table.DefaultView

Bob
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now