SimpleShape.BackColor Property


Gets or sets the background color for the shape.

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

public Color BackColor { get; set; }

Property Value

Type: System.Drawing.Color

A Color that represents the background color of the shape. The default is the value of the DefaultBackColor property.

The BackColor property has no effect when the BackStyle property is set to Transparent or when FillStyle is set to Solid.

Notes to Inheritors:

When overriding the BackColor property in a derived class, use the BackColor property of the base class to extend the base implementation. Otherwise, you must provide all the implementation. You are not required to override both the get and set accessors of the BackColor property; you can override only one if you have to.

The following example shows how to use the BackColor property to switch the color of a shape back and forth between two colors. This example requires that you have an OvalShape control named OvalShape1 on a form.

private void ovalShape1_Click(System.Object sender, System.EventArgs e)
    // Set the BackStyle and FillStyle.
    ovalShape1.BackStyle = BackStyle.Opaque;
    ovalShape1.FillStyle = FillStyle.Transparent;
    // Change the color between red and blue.
    if (ovalShape1.BackColor == Color.Red)
        ovalShape1.BackColor = Color.Blue;
        ovalShape1.BackColor = Color.Red;
Return to top