IDesignerFilter 介面

定義

提供一個介面,讓設計師能夠存取並過濾儲存屬性、屬性及事件描述符的字典 TypeDescriptor ,這些描述符是元件設計師可向設計時環境暴露的。

public interface class IDesignerFilter
public interface IDesignerFilter
type IDesignerFilter = interface
Public Interface IDesignerFilter
衍生

範例

以下範例展示了 PreFilterProperties 的覆寫,當設計者在設計時選擇控制項時,會將設計者的屬性加入屬性視窗。 請參考 ControlDesigner 該類別範例,裡面有一個完整的設計器範例,使用了該 IDesignerFilter 介面。

protected:
   [ReflectionPermission(SecurityAction::Demand, Flags=ReflectionPermissionFlag::MemberAccess)]
   virtual void PreFilterProperties( System::Collections::IDictionary^ properties ) override
   {
      properties->Add( "OutlineColor", TypeDescriptor::CreateProperty( TestControlDesigner::typeid, "OutlineColor", System::Drawing::Color::typeid, nullptr ) );
   }
// Adds a property to this designer's control at design time 
// that indicates the outline color to use. 
// The DesignOnlyAttribute ensures that the OutlineColor
// property is not serialized by the designer.
protected override void PreFilterProperties(System.Collections.IDictionary properties)
{
    PropertyDescriptor pd = TypeDescriptor.CreateProperty(
        typeof(ExampleControlDesigner), 
        "OutlineColor",
        typeof(System.Drawing.Color),
        new Attribute[] { new DesignOnlyAttribute(true) });

    properties.Add("OutlineColor", pd);
}
' Adds a property to this designer's control at design time 
' that indicates the outline color to use.
' The DesignOnlyAttribute ensures that the OutlineColor
' property is not serialized by the designer.
Protected Overrides Sub PreFilterProperties(ByVal properties As System.Collections.IDictionary)
    Dim pd As PropertyDescriptor = TypeDescriptor.CreateProperty( _
    GetType(ExampleControlDesigner), _
    "OutlineColor", _
    GetType(System.Drawing.Color), _
    New Attribute() {New DesignOnlyAttribute(True)})

    properties.Add("OutlineColor", pd)
End Sub

備註

IDesignerFilter 使設計者能夠過濾其相關元件透過 TypeDescriptorS 暴露的屬性、屬性及事件描述符集合。 此介面中名稱以 開頭 Pre 的方法會被呼叫,緊接著名稱以 開頭 Post的方法。

如果你想新增屬性、事件或屬性描述符,請使用 PreFilterAttributesPreFilterEvents, 或 PreFilterProperties 方法。

如果你想更改或移除屬性、事件或屬性描述符,請使用 PostFilterAttributesPostFilterEvents, 或 PostFilterProperties 的方法。

方法

名稱 Description
PostFilterAttributes(IDictionary)

當在衍生類別中覆寫時,允許設計者更改或移除其 TypeDescriptor透過 .

PostFilterEvents(IDictionary)

當在衍生類別中覆寫時,允許設計者更改或移除透過 TypeDescriptor揭露事件集合中的項目。

PostFilterProperties(IDictionary)

當在衍生類別中覆寫時,允許設計者更改或移除透過 TypeDescriptor.

PreFilterAttributes(IDictionary)

當在衍生類別中覆寫時,允許設計者將項目加入其 TypeDescriptor透過 .

PreFilterEvents(IDictionary)

當在衍生類別中覆寫時,允許設計者將項目加入其 TypeDescriptor透過 .

PreFilterProperties(IDictionary)

當在衍生類別中覆寫時,允許設計者將項目加入其透過 揭露 TypeDescriptor的屬性集合。

適用於

另請參閱