Moving items in a listview? up and down either dragging or with buttons


Author
Message
Charles R Hankey
Charles R Hankey
StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)
Group: Forum Members
Posts: 524, Visits: 30K
I want to display the contents of a BO in a List/Listview/grid whatever for the sole purpose of the user being able to rearrange or modify the order of the list ( I will then write back the new position into the sequence number field of the table)



Ideally, I would use the new StratalistView control, but it would also be fine to use the current SF Listview. Dragging and dropping to new position with the mouse would be fine, selecting a using arrows to move would be fine or just having buttons to move the item up and down the way it is done with fields in DDT would be fine.



I think I'm missing something easy.



Suggestions?
Replies
Charles R Hankey
Charles R Hankey
StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)
Group: Forum Members
Posts: 524, Visits: 30K
Hi Ivan



I thought about doing something like that but it seems the framework uses the buttons a lot for things like item lists and I thought there might be some command in the listview or something that could be called from the button that changes the item's position in the list. ????
Trent Taylor
Trent Taylor
StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 7K
This is something that we do a fair amount in the medical application. There are a number of places that we need to have things ranked. In these situations, we will create a toolstrip button for both up and down. Then create a single method that supports the entire logic and simply extract and re-insert the list item either ahead or behind (depending on moving up or down). Here is an example using the ListView. But you could do the same thing with the StrataListView:



Private Sub MoveItem(ByVal moveDown As Boolean)

If lstList.SelectedItems.Count = 0 Then Exit Sub



'-- Establish Locals

Dim item As ListViewItem

Dim index As Integer = lstList.SelectedIndices(0)



'-- Determine which way to move the item

If moveDown Then

'-- See if a move down is possible

If index = lstList.Items.Count - 1 Then Exit Sub



'-- Extract the item from the list

item = lstList.Items(index)

lstList.Items.Remove(item)



'-- Insert the item

lstList.Items.Insert(index + 1, item)

Else

'-- See if the item can be moved up

If lstList.SelectedIndices(0) = 0 Then Exit Sub



'-- Extract the item from the list

item = lstList.Items(index)

lstList.Items.Remove(item)



'-- Insert the item

lstList.Items.Insert(index - 1, item)

End If



'-- May need to update some toolbar items, menus, etc. after the change is made. Do that now.

SetMenuItems()

End Sub

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Threaded View
Threaded View
Charles R Hankey - 17 Years Ago
Ivan George Borges - 17 Years Ago
Charles R Hankey - 17 Years Ago
Trent L. Taylor - 17 Years Ago
Charles R Hankey - 17 Years Ago
Charles R Hankey - 17 Years Ago
Trent L. Taylor - 17 Years Ago
                 Yep, perfect! Sorry for the silly idea, Charles.
Ivan George Borges - 17 Years Ago
                     Hi Ivan,

Nice to see you back! where have you been? :w00t:
Edhy Rijo - 17 Years Ago
                         Hey Edhy! Well... cruising around the world. (yep, I daydream) Just...
Ivan George Borges - 17 Years Ago
                             I was noodling around with this with Charles and it worked great. We...
Greg McGuffey - 17 Years Ago
                                 This is a bit strange and without getting my hands on the code this...
Trent L. Taylor - 17 Years Ago
                                     Here is a sample app. I'm pretty stumped. I upgraded to latest...
Greg McGuffey - 17 Years Ago
                                         Has anyone had a chance to take a look at this yet?
Greg McGuffey - 17 Years Ago
                                             Nope :)
Trent L. Taylor - 17 Years Ago

Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search