Solved

# sorting items in a listview

Posted on 2003-03-06
Medium Priority
180 Views
Hello, I am having a bit of a problem ordering items in a listview.  I actually have two listviews.  On the top one, you double click an item, and it goes down to the bottom one.  This works perfectly.  However, I would like them not to remain in the order that they are in the top listview.  For instance, I want whatever item I click on first to be the first item in the bottom one, second to be the second in the bottom one, and so forth.  Is this possible?  Thanks in advance.
-Al
0
Question by:afeld
[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

Accepted Solution

selectgt earned 200 total points
ID: 8082457
hmm.. not exactly sure what you're saying but hopefully this will help.  I just whipped it up as an example maybe you could look over and find useful?

Dim itmX As ListItem, tmpPosition As Integer
tmpPosition = ListView2.ListItems.Count - 1
Set itmX = ListView2.ListItems.Add(tmpPosition, ListView1.SelectedItem.Key, ListView1.SelectedItem.Text)
itmX.SubItems(1) = ListView1.SelectedItem.SubItems(1)
itmX.SubItems(2) = ListView1.SelectedItem.SubItems(2)
ListView1.ListItems.Remove ListView1.SelectedItem.Index
0

LVL 27

Expert Comment

ID: 8082802
selectgt's solution looks right to me, as the first parameter of .ListItems.Add determines WHERE in the listview the new item is added to.

On the other hand, a listview will naturally add items in the order they are placed, so you should not have had a problem in the first place!

My guess is that you probably have set the second listview to have the same sort order as your first one.

Please make sure that your bottom ListView has the sorted property set to false (and that you do not set it to true in code)

If it was set to true, then your original program should already sort the items properly. If this is not the case, then the selectgt's code should solve the problem for you.
0

Expert Comment

ID: 8900551
afeld:
Experts: Post your closing recommendations!  Who deserves points here?
0

Author Comment

ID: 8903052
Sorry, I let this one get away and forgot about it.  Thanks all for answers.
-AL
0

## Featured Post

Question has a verified solution.

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

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
###### Suggested Courses
Course of the Month8 days, 5 hours left to enroll