Results 1 to 4 of 4

Threaded View

  1. #1

    Thread Starter
    PowerPoster JuggaloBrotha's Avatar
    Join Date
    Sep 2005
    Lansing, MI; USA

    ListBox/ListView Move Item with Mouse

    First off I didn't write the actual code for the re-positioning of the ListViewItem, but I did convert it from c# to vb.net and I did make it it's own control rather than handling the mouse events on the form. Here's the CodeProject article I used to create the control: Manual reordering of items inside a ListView

    and here's the guy who made it: mav.northwind

    Anyways, this control is inherited from the Framework's ListView and has these properties added:
    • ItemMoveEnabled (Boolean) items can only be rearranged if this is True, otherwise it's disabled.
    • InsertionLineColor (Color) this control draws a line between items to show where the item would be place and the color of the line is handled by this property. Default is Red.
    These properties are removed:
    • MultiSelect (Boolean) Right now this can only be handled 1 item at a time and Multiselect has to be set to False so this property is suppressed and hidden for now, I may get it to work with multiple items later, we'll see.

    Events that have been added:
    • ItemMoveEnabledChanged this fires when the ItemMoveEnabled property has changed.
    • ItemMoved this fires right after you release the item with the mouse and if the item was actually moved. e.CurrentIndex (Int) is the index of where the item was and e.NewIndex (int) is where the item has moved to. This is particularly useful if you have a collection and you need to rearrange the associated item in the collection.

    Name:  MoveItemLists.jpg
Views: 4775
Size:  49.0 KB
    To use the control simply add the MoveItemListView.vb/MoveItemListBox.v, or both, and ItemMovedEventArgs.vb files to your project, build it then in the form designer it appears in the ToolBox at the top just drag and drop it on the form and viola use it like a regular ListView.

    Update 2010-Feb-12:
    • Fixed an issue with the ListView in which the InsertionLine wouldn't disappear if the mouse left the LV during an item re-position.
    • Moved the ItemMovedEventArgs class to a separate file, which is required by both the MoveItemListView but also the MoveItemListBox
    • Applied the LV's item re-position to work with a ListBox and made a control with the same events added and added it here.

    Update 2010-Feb-18: Added a CheckedListBox.
    Update 2010-June-03: Added the ToolBoxBitmap.
    Attached Files Attached Files
    Last edited by JuggaloBrotha; Jun 3rd, 2010 at 12:39 PM. Reason: Updated attachments

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts


Click Here to Expand Forum to Full Width

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.