954,529 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

ListView Sort Question

I have 6 rows of items in a ListView within 2 columns that are listed like so:

1    Milk
2    Pepsi
3    Juice
4    Water
5    Coffee
6    Tea


I'm trying to make it so when you modify the number in the first column, it will sort the list based on the first column's number in ascending order. But that's the easy part.

The hard part is making it so that if you change the number in the first column to a number that already exists in the list it will bump the existing row down and change the numbers in the first column to correspond to the change. For example...

If I change the 6 in the first column to a 5, the fifth row will be bumped down to row 6, the sixth row will be bumped up to row 5 and the number in the first column will increase/decrease to compensate the change.

How can this be accomplished?

Sucrose
Newbie Poster
1 post since Sep 2010
Reputation Points: 10
Solved Threads: 0
 

Here is a way(maybe it is not the best):

1. write your sort procedure
2. define two form properties or variables : ListIndex and ValueFromIndex
3. when user clicks on a row (OnSelectIdem maybe, or OnClick), do
- check if the previous row(the row with the index ListIndex) has the value changed (it is different from ValueFromIndex). If so, sort the list
- update ListIndex and ValueFromIndex with the values from the current item

Ionut

Ionelul
Junior Poster in Training
94 posts since Dec 2009
Reputation Points: 17
Solved Threads: 27
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: