Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 276
  • 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
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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