Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Color Property
Collapse the table of content
Expand the table of content

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.
    myListView.Items.Add("zero");
    myListView.Items.Add("one");
    myListView.Items.Add("two");
    myListView.Items.Add("three");
    myListView.Items.Add("four");
    myListView.Items.Add("five");

    // 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";
    this.Controls.Add(myListView);
}

.NET Framework

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

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
Show:
© 2015 Microsoft