Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

ListViewInsertionMark.Color Property

Gets or sets the color of the insertion mark.

Namespace:  System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)
public Color Color { get; set; }

Property Value

Type: System.Drawing.Color
A Color value that represents the color of the insertion mark. The default value is the value of the ListView.ForeColor property.

Use this property to set the insertion mark color to a value other than the foreground color of the ListView control.

The following code example demonstrates how to use the ListView insertion mark feature and implements drag-and-drop item reordering using the standard drag events. The position of the insertion mark is updated in a handler for the Control.DragOver event. In this handler, the position of the mouse pointer is compared to the midpoint of the nearest item, and the result is used to determine whether the insertion mark appears to the left or the right of the item.

For the complete example, see the ListViewInsertionMark overview reference topic.

public ListViewInsertionMarkExample()
    // Initialize myListView.
    myListView = new ListView();
    myListView.Dock = DockStyle.Fill;
    myListView.View = View.LargeIcon;
    myListView.MultiSelect = false;
    myListView.ListViewItemSorter = new ListViewIndexComparer();

    // Initialize the insertion mark.
    myListView.InsertionMark.Color = Color.Green;

    // Add items to myListView.

    // Initialize the drag-and-drop operation when running 
    // under Windows XP or a later operating system. 
    if (OSFeature.Feature.IsPresent(OSFeature.Themes))
        myListView.AllowDrop = true;
        myListView.ItemDrag += new ItemDragEventHandler(myListView_ItemDrag);
        myListView.DragEnter += new DragEventHandler(myListView_DragEnter);
        myListView.DragOver += new DragEventHandler(myListView_DragOver);
        myListView.DragLeave += new EventHandler(myListView_DragLeave);
        myListView.DragDrop += new DragEventHandler(myListView_DragDrop);

    // Initialize the form. 
    this.Text = "ListView Insertion Mark Example";

.NET Framework

Supported in: 4.5.1, 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
© 2014 Microsoft. All rights reserved.