共用方式為


Shape.SelectionColor 屬性

取得或設定圖形的選取範圍色彩。

命名空間:  Microsoft.VisualBasic.PowerPacks
組件:  Microsoft.VisualBasic.PowerPacks.Vs (在 Microsoft.VisualBasic.PowerPacks.Vs.dll 中)

語法

'宣告
<BrowsableAttribute(True)> _
Public Property SelectionColor As Color
[BrowsableAttribute(true)]
public Color SelectionColor { get; set; }
[BrowsableAttribute(true)]
public:
property Color SelectionColor {
    Color get ();
    void set (Color value);
}
[<BrowsableAttribute(true)>]
member SelectionColor : Color with get, set
function get SelectionColor () : Color 
function set SelectionColor (value : Color)

屬性值

類型:Color
AColor在執行階段選取的圖形時表示焦點矩形的色彩。預設為 Highlight

備註

SelectionColor屬性可用來變更焦點矩形的色彩顯示時LineShapeOvalShape,或RectangleShape在執行階段選取控制項。 如果CanFocusCanSelect屬性會設為false,會忽略這個屬性。

範例

下列範例示範如何使用SelectionColor屬性來變更色彩取決於焦點矩形BackColor表單的屬性。 此範例中您需要RectangleShape名 RectangleShape1 為表單上的控制項。

Private Sub RectangleShape1_GotFocus() Handles RectangleShape1.GotFocus
    ' If SelectionColor is the same as the form's BackColor. 
    If RectangleShape1.SelectionColor = Me.BackColor Then 
        ' Change the SelectionColor.
        RectangleShape1.SelectionColor = Color.Red
    Else 
        ' Use the default SelectionColor.
        RectangleShape1.SelectionColor = SystemColors.Highlight
    End If 
End Sub
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;
    }
}

.NET Framework 安全性

請參閱

參考

Shape 類別

Microsoft.VisualBasic.PowerPacks 命名空間

其他資源

如何:使用 LineShape 控制項繪製線條 (Visual Studio)

如何:使用 OvalShape 和 RectangleShape 控制項繪製圖案 (Visual Studio)

Line 和 Shape 控制項簡介 (Visual Studio)