Solved

Sorting ListView Items

Posted on 2006-11-20
7
240 Views
Last Modified: 2010-04-23
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
Comment
Question by:mohammadalsayeh
  • 4
  • 2
7 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 17978936
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
 

Author Comment

by:mohammadalsayeh
ID: 17979850
but I want to sort it before I display it on a listview


0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 17979922
What are you displaying?  Where are you getting the data to display in the ListView?

Bob
0
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 
LVL 15

Expert Comment

by:Solar_Flare
ID: 17984844
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
 

Author Comment

by:mohammadalsayeh
ID: 17985513
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
 
LVL 96

Expert Comment

by:Bob Learned
ID: 17986368
How did you try to sort the DefaultView, and why didn't it work?

   table.DefaultView.Sort = "Variable DESC"

Bob
0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 250 total points
ID: 17986374
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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Convert an ASPX page into PDF 7 31
Get the selected ValueMember of Combobox 5 30
Store results in vb.net 3 20
Sending receiving text messages in vb.net 15 32
This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

816 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now