Shape.Enabled 屬性
取得或設定值,表示線條或圖形控制項是否可回應使用者互動。
命名空間: Microsoft.VisualBasic.PowerPacks
組件: Microsoft.VisualBasic.PowerPacks.Vs (在 Microsoft.VisualBasic.PowerPacks.Vs.dll 中)
語法
'宣告
<BrowsableAttribute(True)> _
Public Property Enabled As Boolean
[BrowsableAttribute(true)]
public bool Enabled { get; set; }
[BrowsableAttribute(true)]
public:
property bool Enabled {
bool get ();
void set (bool value);
}
[<BrowsableAttribute(true)>]
member Enabled : bool with get, set
function get Enabled () : boolean
function set Enabled (value : boolean)
屬性值
類型:Boolean
如果控制項可以回應使用者互動,則為 true,否則為 false。預設為 true。
備註
與Enabled屬性,您可以防止線條與圖形選取在執行階段。 您也可以停用不會套用到應用程式的目前狀態的控制項。 若要防止使用者按一下它,直到符合特定條件,模擬按鈕的行為,例如停用圖形。
範例
下列範例示範如何啟用和停用RectangleShape控制項在執行階段。 此程式碼需要您具有Form與RectangleShape控制項和TextBox在其上的控制項。
Private Sub TextBox1_TextChanged() Handles TextBox1.TextChanged
' If the TextBox contains text, enable the RectangleShape.
If TextBox1.Text <> "" Then
' Enable the RectangleShape.
RectangleShape1.Enabled = True
' Change the BorderColor to the default.
RectangleShape1.BorderColor =
Microsoft.VisualBasic.PowerPacks.Shape.DefaultBorderColor
Else
' Disable the RectangleShape control.
RectangleShape1.Enabled = False
' Change the BorderColor to show that the control is disabled
RectangleShape1.BorderColor =
Color.FromKnownColor(KnownColor.InactiveBorder)
End If
End Sub
private void textBox1_TextChanged(object sender, System.EventArgs e)
{
// If the TextBox contains text, enable the RectangleShape.
if (textBox1.Text != "")
// Enable the RectangleShape.
{
rectangleShape1.Enabled = true;
// Change the BorderColor to the default.
rectangleShape1.BorderColor = Microsoft.VisualBasic.PowerPacks.Shape.DefaultBorderColor;
}
else
{
// Disable the RectangleShape control.
rectangleShape1.Enabled = false;
// Change the BorderColor to show that the control is disabled
rectangleShape1.BorderColor = Color.FromKnownColor(KnownColor.InactiveBorder);
}
}
.NET Framework 安全性
- 完全信任立即呼叫者。這個成員無法供部分信任的程式碼使用。如需詳細資訊,請參閱從部分受信任程式碼使用程式庫。
請參閱
參考
Microsoft.VisualBasic.PowerPacks 命名空間
其他資源
如何:使用 LineShape 控制項繪製線條 (Visual Studio)