SelectionColor Property

Shape.SelectionColor Property

 

Gets or sets the selection color of a shape.

Namespace:   Microsoft.VisualBasic.PowerPacks
Assembly:  Microsoft.VisualBasic.PowerPacks.Vs (in Microsoft.VisualBasic.PowerPacks.Vs.dll)

[BrowsableAttribute(true)]
public Color SelectionColor { get; set; }

Property Value

Type: System.Drawing.Color

A Color that represents the color of the focus rectangle when a shape is selected at run time. The default is Highlight.

The SelectionColor property can be used to change the color of the focus rectangle that is displayed when a LineShape, OvalShape, or RectangleShape control is selected at run time. If the CanFocus or CanSelect properties are set to false, this property is ignored.

The following example demonstrates how to use the SelectionColor property to change the color of the focus rectangle depending on the BackColor property of the form. This example requires that you have a RectangleShape control named RectangleShape1 on a form.

private void rectangleShape1_GotFocus(object sender, System.EventArgs e)
{
    // If SelectionColor is the same as the form's BackColor.
    if (rectangleShape1.SelectionColor == this.BackColor)
    // Change the SelectionColor.
    {
        rectangleShape1.SelectionColor = Color.Red;
    }
    else
    {
        // Use the default SelectionColor.
        rectangleShape1.SelectionColor = SystemColors.Highlight;
    }
}
Return to top
Show:
© 2016 Microsoft