Item Reordering



Item reordering is not supported in Better ListView Express.



Changing item order by dragging items can be turned on by setting ItemReorderMode to one of the following values:

The reordering is realized through Drag and Drop mechanism.

Item reordering can supports groups and item hierarchy.

Target location of reordered items is displayed using Insertion mark. If the reordering cannot be performed (e.g. when inserting item between its own children), then the insertion mark is displayed as disabled and the reordering will not be performed.

Reordering Options

There are several item reordering options to adjust the feature for working with groups and hierarchical items. These options can be used as flags of the enumm property ItemReorderOptions:

None of the extra options are on by default so the default value is ItemReorderOptions.None.

Auto-Expansion Checking

Auto expansion checking is performed during item reordering and looks whether it is valid to auto expand item over which mouse cursor hovers. By default, there is only one situation when auto expansion is not allowed: Item which is auto-collapsed will not be than auto-expanded again.

It is possible to add custom checking (e.g. when some items or groups should not expand when user drags items over it) by handling CheckAutoExpand event and than set BetterListViewCheckAutoExpandEventArgs.IsValid to false whenever you want to deny auto-expansion. Event data contains both source and target items.

Item Reordering Checking

Item reorder checking is performed during item reordering and looks whether an item is not put into itself (into its own children). For example, when AllowCreateChild reordering option is enabled, then the check looks whether user is not making child item under the reordered item.

It is possible to add custom checking (e.g. when item should not be placed some specific locations with item reordering) by handling CheckItemReorder event and then set BetterListViewCheckItemReorderEventArgs.IsValid to false. Event data contains source items, target location and current reordering options.

Sample Source Code

C#

this.listView.BeginUpdate();

this.listView.Columns.Add("column");

this.listView.Items.AddRange(
    new[]
    {
        "first item",
        "second item",
        "third item",
        "fourth item",
        "fifth item"
    });

// enable item reordering
this.listView.ItemReorderMode = BetterListViewItemReorderMode.Enabled;

this.listView.EndUpdate();

Visual Basic

ListView.BeginUpdate()

ListView.Columns.Add ("column")

ListView.Items.AddRange (
    New String() { _
                     "first item",
                     "second item",
                     "third item",
                     "fourth item",
                     "fifth item"
                 })

' enable item reordering
ListView.ItemReorderMode = BetterListViewItemReorderMode.Enabled

ListView.EndUpdate()