ToolboxDataAttribute 類別
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
指定在工具箱(如 Microsoft Visual Studio)中從工具箱拖曳自訂控制項時產生的預設標籤。
public ref class ToolboxDataAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.Class)]
public sealed class ToolboxDataAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.Class)>]
type ToolboxDataAttribute = class
inherit Attribute
Public NotInheritable Class ToolboxDataAttribute
Inherits Attribute
- 繼承
- 屬性
範例
[ ToolboxData("<{0}:MyLabel runat= server Text=
MyLabel><{0}:MyLabel>") ]public class MyLabel : Label {...}
在以下程式碼範例中,前述程式碼設定了數個特定於 MyLabel的屬性。 所有 的 {0} 出現都會由設計者以與 MyLabel 類別相關的標籤前綴取代。
using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace CustomControls
{
[ ToolboxData("<{0}:MyLabel Text='MyLabel' BorderColor='Yellow' BackColor='Magenta' BorderWidth = '10' runat='server'></{0}:MyLabel>") ]
public class MyLabel : Label
{
public MyLabel()
{
// Your code goes here.
}
}
}
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls
Namespace CustomControls
<ToolboxData("<{0}:MyLabel Text='MyLabel' BorderColor='Yellow' BackColor='Magenta' BorderWidth = '10' runat='server'></{0}:MyLabel>")> _
Public Class MyLabel
Inherits Label
Public Sub New()
'Your code goes here.
End Sub
End Class
End Namespace 'CustomControls
備註
預設情況下,像 Visual Studio 這類工具的視覺設計師會建立一個空標籤。 這是一個標籤,代表控制項預設狀態,當控制項從視覺設計師的工具箱中移除到設計表面時。 為了指定初始預設值,控制項可以使用此屬性。 你可以利用這個屬性自訂當控制器從工具箱拖曳到表單時,設計器中放置的初始 HTML 內容。
建構函式
| 名稱 | Description |
|---|---|
| ToolboxDataAttribute(String) |
初始化 ToolboxDataAttribute 類別的新執行個體。 |
欄位
| 名稱 | Description |
|---|---|
| Default |
代表自訂控制項的預設 ToolboxDataAttribute 值。 |
屬性
| 名稱 | Description |
|---|---|
| Data |
取得代表控制項屬性初始值的字串,該字串用於視覺化設計器中建立控制項實例。 |
| TypeId |
在衍生類別中實作時,取得這個 Attribute的唯一標識碼。 (繼承來源 Attribute) |
方法
| 名稱 | Description |
|---|---|
| Equals(Object) |
測試該 ToolboxDataAttribute 物件是否等於給定物件。 |
| GetHashCode() |
回傳自訂控制項的雜湊碼。 |
| GetType() |
取得目前實例的 Type。 (繼承來源 Object) |
| IsDefaultAttribute() |
測試物件是否 ToolboxDataAttribute 包含該 Data 屬性的預設值。 |
| Match(Object) |
在衍生類別中覆寫時,傳回值,指出這個實例是否等於指定的物件。 (繼承來源 Attribute) |
| MemberwiseClone() |
建立目前 Object的淺層複本。 (繼承來源 Object) |
| ToString() |
傳回表示目前 物件的字串。 (繼承來源 Object) |
明確介面實作
| 名稱 | Description |
|---|---|
| _Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr) |
將一組名稱對應至一組對應的分派識別項 (Dispatch Identifier)。 (繼承來源 Attribute) |
| _Attribute.GetTypeInfo(UInt32, UInt32, IntPtr) |
擷取 物件的型別資訊,可用來取得介面的類型資訊。 (繼承來源 Attribute) |
| _Attribute.GetTypeInfoCount(UInt32) |
擷取物件提供的類型資訊介面數目 (0 或 1)。 (繼承來源 Attribute) |
| _Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr) |
提供物件所公開屬性和方法的存取權。 (繼承來源 Attribute) |