﻿<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>StrataFrame Forum » StrataFrame Application Framework - V1 » WinForms (How do I?)  » Moving items in a listview? up and down either dragging or with buttons</title><generator>InstantForum 2017-1 Final</generator><description>StrataFrame Forum</description><link>http://forum.strataframe.net/</link><webMaster>StrataFrame Forum</webMaster><lastBuildDate>Tue, 26 May 2026 20:36:31 GMT</lastBuildDate><ttl>20</ttl><item><title>Moving items in a listview? up and down either dragging or with buttons</title><link>http://forum.strataframe.net/FindPost24997.aspx</link><description>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)&lt;br&gt;
&lt;br&gt;
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.&lt;br&gt;
&lt;br&gt;
I think I'm missing something easy.&lt;br&gt;
&lt;br&gt;
Suggestions?</description><pubDate>Fri, 30 Oct 2009 13:59:41 GMT</pubDate><dc:creator>Charles R Hankey</dc:creator></item><item><title>RE: Moving items in a listview? up and down either dragging or with buttons</title><link>http://forum.strataframe.net/FindPost25085.aspx</link><description>Nope :)</description><pubDate>Fri, 30 Oct 2009 13:59:41 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item><item><title>RE: Moving items in a listview? up and down either dragging or with buttons</title><link>http://forum.strataframe.net/FindPost25084.aspx</link><description>Has anyone had a chance to take a look at this yet?</description><pubDate>Fri, 30 Oct 2009 13:57:48 GMT</pubDate><dc:creator>Greg McGuffey</dc:creator></item><item><title>RE: Moving items in a listview? up and down either dragging or with buttons</title><link>http://forum.strataframe.net/FindPost25041.aspx</link><description>Here is a sample app.  I'm pretty stumped.  I upgraded to latest official release (1.7.0.2) and tried it on two machines. They are both XP though.</description><pubDate>Wed, 28 Oct 2009 17:04:47 GMT</pubDate><dc:creator>Greg McGuffey</dc:creator></item><item><title>RE: Moving items in a listview? up and down either dragging or with buttons</title><link>http://forum.strataframe.net/FindPost25038.aspx</link><description>This is a bit strange and without getting my hands on the code this could be hard to diagnose this way.  This is ringing a bell with me but I can't put my finder on the answer....but it does sound familiar?!?</description><pubDate>Wed, 28 Oct 2009 13:45:08 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item><item><title>RE: Moving items in a listview? up and down either dragging or with buttons</title><link>http://forum.strataframe.net/FindPost25011.aspx</link><description>I was noodling around with this with Charles and it worked great. We even made a component that you could drop on a form, set three properties and boom, order of items in listview is easily changeable. We made it specific to a SF ListView. He has the latest and greatest SF on Vista.&lt;br&gt;
&lt;br&gt;
Then I tried to reproduce this in my environment, XP with 1.6.7. I used a plain old vanilla .NET ListView.  It doesn't work.  No matter what I use for this line as the index:&lt;br&gt;
&lt;br&gt;
[codesnippet]this.List.Items.Insert(index, item);[/codesnippet] &lt;br&gt;
&lt;br&gt;
it inserts the item back in the same position. Thus:&lt;br&gt;
&lt;br&gt;
[codesnippet]this.List.Items.Insert(0, item);&lt;br&gt;
this.List.Items.Insert(34, item);&lt;br&gt;
this.List.Items.Insert(23454, item);[/codesnippet] &lt;br&gt;
&lt;br&gt;
all put the item back exactly in the same position as it was to start. I.e. if the original index of the item is, say, 10, then each of these will put the item back at index 10.&lt;br&gt;
&lt;br&gt;
Any ideas what might be causing this?  I tried this with a target of 2.0 and 3.5. Same diff.&lt;br&gt;
&lt;br&gt;</description><pubDate>Tue, 27 Oct 2009 15:08:46 GMT</pubDate><dc:creator>Greg McGuffey</dc:creator></item><item><title>RE: Moving items in a listview? up and down either dragging or with buttons</title><link>http://forum.strataframe.net/FindPost25010.aspx</link><description>Hey Edhy!&lt;/P&gt;&lt;P&gt;Well... cruising around the world. (yep, I daydream)&lt;/P&gt;&lt;P&gt;Just too busy. But I was reading the posts every chance I got. Have read lots of yours, very good ones actually.&lt;/P&gt;&lt;P&gt;How've you been?</description><pubDate>Tue, 27 Oct 2009 09:22:44 GMT</pubDate><dc:creator>Ivan George Borges</dc:creator></item><item><title>RE: Moving items in a listview? up and down either dragging or with buttons</title><link>http://forum.strataframe.net/FindPost25008.aspx</link><description>Hi Ivan,&lt;br&gt;
&lt;br&gt;
Nice to see you back! where have you been? :w00t:</description><pubDate>Tue, 27 Oct 2009 08:40:05 GMT</pubDate><dc:creator>Edhy Rijo</dc:creator></item><item><title>RE: Moving items in a listview? up and down either dragging or with buttons</title><link>http://forum.strataframe.net/FindPost25006.aspx</link><description>Yep, perfect!&lt;/P&gt;&lt;P&gt;Sorry for the silly idea, Charles.</description><pubDate>Tue, 27 Oct 2009 08:14:34 GMT</pubDate><dc:creator>Ivan George Borges</dc:creator></item><item><title>RE: Moving items in a listview? up and down either dragging or with buttons</title><link>http://forum.strataframe.net/FindPost25005.aspx</link><description>[quote]I assume moving an item moves the subitems along with it?&lt;BR&gt;[/quote]&lt;/P&gt;&lt;P&gt;Yes.&amp;nbsp; A sub item belongs to the actual item.&amp;nbsp; This is the same type of logic that the standard ListView used and we just followed suit to try and make the learning curve slightly less.</description><pubDate>Mon, 26 Oct 2009 20:49:42 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item><item><title>RE: Moving items in a listview? up and down either dragging or with buttons</title><link>http://forum.strataframe.net/FindPost25004.aspx</link><description>Worked great on the listview.  I'm putting into a shared sub in my util library and passing in the Listview by reference.  &lt;br&gt;
&lt;br&gt;
Will have another for the Stratalistview.  &lt;br&gt;
&lt;br&gt;</description><pubDate>Mon, 26 Oct 2009 20:02:20 GMT</pubDate><dc:creator>Charles R Hankey</dc:creator></item><item><title>RE: Moving items in a listview? up and down either dragging or with buttons</title><link>http://forum.strataframe.net/FindPost25003.aspx</link><description>Thanks Trent.  &lt;br&gt;
&lt;br&gt;
I am about to try this with a listview and a stratalistview.&lt;br&gt;
&lt;br&gt;
I assume moving an item moves the subitems along with it?&lt;br&gt;</description><pubDate>Mon, 26 Oct 2009 18:48:48 GMT</pubDate><dc:creator>Charles R Hankey</dc:creator></item><item><title>RE: Moving items in a listview? up and down either dragging or with buttons</title><link>http://forum.strataframe.net/FindPost25000.aspx</link><description>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:&lt;br&gt;
&lt;br&gt;
[codesnippet]Private Sub MoveItem(ByVal moveDown As Boolean)&lt;br&gt;
    If lstList.SelectedItems.Count = 0 Then Exit Sub&lt;br&gt;
&lt;br&gt;
    '-- Establish Locals&lt;br&gt;
    Dim item As ListViewItem&lt;br&gt;
    Dim index As Integer = lstList.SelectedIndices(0)&lt;br&gt;
&lt;br&gt;
    '-- Determine which way to move the item&lt;br&gt;
    If moveDown Then&lt;br&gt;
        '-- See if a move down is possible&lt;br&gt;
        If index = lstList.Items.Count - 1 Then Exit Sub&lt;br&gt;
&lt;br&gt;
        '-- Extract the item from the list&lt;br&gt;
        item = lstList.Items(index)&lt;br&gt;
        lstList.Items.Remove(item)&lt;br&gt;
&lt;br&gt;
        '-- Insert the item&lt;br&gt;
        lstList.Items.Insert(index + 1, item)&lt;br&gt;
    Else&lt;br&gt;
        '-- See if the item can be moved up&lt;br&gt;
        If lstList.SelectedIndices(0) = 0 Then Exit Sub&lt;br&gt;
&lt;br&gt;
        '-- Extract the item from the list&lt;br&gt;
        item = lstList.Items(index)&lt;br&gt;
        lstList.Items.Remove(item)&lt;br&gt;
&lt;br&gt;
        '-- Insert the item&lt;br&gt;
        lstList.Items.Insert(index - 1, item)&lt;br&gt;
    End If&lt;br&gt;
&lt;br&gt;
    '-- May need to update some toolbar items, menus, etc. after the change is made.  Do that now.&lt;br&gt;
    SetMenuItems()&lt;br&gt;
End Sub[/codesnippet]</description><pubDate>Mon, 26 Oct 2009 17:19:16 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item><item><title>RE: Moving items in a listview? up and down either dragging or with buttons</title><link>http://forum.strataframe.net/FindPost24999.aspx</link><description>Hi Ivan&lt;br&gt;
&lt;br&gt;
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. ????</description><pubDate>Mon, 26 Oct 2009 16:54:37 GMT</pubDate><dc:creator>Charles R Hankey</dc:creator></item><item><title>RE: Moving items in a listview? up and down either dragging or with buttons</title><link>http://forum.strataframe.net/FindPost24998.aspx</link><description>Hey Charles!&lt;/P&gt;&lt;P&gt;Have you got an Order column on the table? Guess that if you have it, it has incremented values in it and the table ir ordered on it, when clicking the Up and Down button on your form could exchange the values from the selected row with the upper or lower row, according to which button was pressed.</description><pubDate>Mon, 26 Oct 2009 15:27:46 GMT</pubDate><dc:creator>Ivan George Borges</dc:creator></item></channel></rss>