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)
属性值
类型:System.Drawing.Color
表示焦点矩形的颜色 Color ,当形状在运行时选择。默认值为 Highlight。
备注
SelectionColor 属性可用于更改显示焦点矩形的颜色,当 LineShape、 OvalShape或 RectangleShape 控件在运行时选择时。 如果 CanFocus 或 CanSelect 属性设置为 false,此属性将被忽略。
示例
下面的示例演示如何使用 SelectionColor 属性基于窗体的 BackColor 属性来更改焦点矩形的颜色。 此示例要求您具有名为在窗体的 RectangleShape1 的一个 RectangleShape 控件。
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 安全性
- 对直接调用方的完全信任。此成员不能由部分信任的代码使用。有关更多信息,请参见通过部分受信任的代码使用库。
请参见
参考
Microsoft.VisualBasic.PowerPacks 命名空间
其他资源
如何:使用 LineShape 控件绘制直线 (Visual Studio)