Solved

Sorting ListView Items

Posted on 2006-11-20
7
257 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

732 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