Adding Sorting Arrows to a ListBox ?? 
Author Message
 Adding Sorting Arrows to a ListBox ??

Hi People,
I have a list box that I would like the user to be able to change the order
of the names listed within by means of highlighting a name and then clicking
on an up or down arrow to move it up or down in the order.

Any ideas???
I have been searching for about 3 hours for a solution on the internet and
my books.

thanks,
Kevin Rea



Wed, 09 Jan 2002 03:00:00 GMT  
 Adding Sorting Arrows to a ListBox ??
Hi Kevin,

perhaps you should try the free Drag List-Control from CCRP.
You find Versions for VB5 and VB6 at
http://www.mvps.org/ccrp/
look in the control info or download section

CU  Ronald
-> Life would be easier if we had the source code.

--


Quote:
> Hi People,
> I have a list box that I would like the user to be able to change the
order
> of the names listed within by means of highlighting a name and then
clicking
> on an up or down arrow to move it up or down in the order.

> Any ideas???
> I have been searching for about 3 hours for a solution on the internet and
> my books.

> thanks,
> Kevin Rea




Fri, 11 Jan 2002 03:00:00 GMT  
 Adding Sorting Arrows to a ListBox ??


Fri, 19 Jun 1992 00:00:00 GMT  
 Adding Sorting Arrows to a ListBox ??
Hi!
On a form, add two ListBoxes (List1 and List2), set the "Visible" property
of List2 to "False", and insert some items in List1; add two CommandButtons
(cmdUP and cmdDOWN); put this code in the declaration section of the form:

Private Sub cmdUP_Click()
    Dim NewIndex As Integer
    Dim X As Integer
    If List1.ListIndex <= 0 Then Exit Sub
    NewIndex = List1.ListIndex - 1
    List2.Clear
    For X = 0 To List1.ListCount - 1
        If X = NewIndex Then
            List2.AddItem List1.Text
            List2.AddItem List1.List(X), NewIndex + 1
        ElseIf X <> NewIndex + 1 Then
            List2.AddItem List1.List(X)
        End If
    Next X
    List1.Clear
    For X = 0 To List2.ListCount - 1
        List1.AddItem List2.List(X)
    Next X
    List1.ListIndex = NewIndex
End Sub

Private Sub cmdDOWN_Click()
    Dim NewIndex As Integer
    Dim X As Integer
    If List1.ListIndex = List1.ListCount - 1 Or List1.ListIndex = -1 Then
Exit Sub
    NewIndex = List1.ListIndex + 1
    List2.Clear
    For X = 0 To List1.ListCount - 1
        If X = NewIndex Then
            List2.AddItem List1.List(X), NewIndex - 1
            List2.AddItem List1.Text
        ElseIf X <> NewIndex - 1 Then
            List2.AddItem List1.List(X)
        End If
    Next X
    List1.Clear
    For X = 0 To List2.ListCount - 1
        List1.AddItem List2.List(X)
    Next X
    List1.ListIndex = NewIndex
End Sub

=====
Note that this code isn't optiomized, but it shows in a clear way how to
change the order of the items in the ListBox. If you have any kind of
problem, feel free to contact me again.

Bye
--

http://www2.armaditaggia.com/marco
http://www.geocities.com/SiliconValley/Foothills/7260/


Quote:
> Hi People,
> I have a list box that I would like the user to be able to change the
order
> of the names listed within by means of highlighting a name and then
clicking
> on an up or down arrow to move it up or down in the order.

> Any ideas???
> I have been searching for about 3 hours for a solution on the internet and
> my books.

> thanks,
> Kevin Rea




Mon, 21 Jan 2002 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Adding Sorting Arrows to a ListBox ??

2. up arrow, down arrow, left arrow, right arrow

3. sorting listbox with sorted property on run time

4. Listbox/Combobox - .Sorted=True doesn't sort ItemData

5. Putting sort-direction arrows on listview columnheaders.

6. ListView Sort Arrows

7. Sort arrows in outlook?

8. Sort Order arrows in ListView ColumnHeaders?

9. ListView Control Sorting Arrow?

10. Showing/Using Sort arrows on vb6 listviews?

11. Sort arrows on column headers for VB6

12. API Code to Add Listbox to Listbox

 

 
Powered by phpBB® Forum Software