PropertyValueUIItemInvokeHandler 代理人

定義

代表將處理 InvokeHandlerPropertyValueUIItem 事件的方法。

public delegate void PropertyValueUIItemInvokeHandler(ITypeDescriptorContext ^ context, PropertyDescriptor ^ descriptor, PropertyValueUIItem ^ invokedItem);
public delegate void PropertyValueUIItemInvokeHandler(ITypeDescriptorContext context, PropertyDescriptor descriptor, PropertyValueUIItem invokedItem);
type PropertyValueUIItemInvokeHandler = delegate of ITypeDescriptorContext * PropertyDescriptor * PropertyValueUIItem -> unit
Public Delegate Sub PropertyValueUIItemInvokeHandler(context As ITypeDescriptorContext, descriptor As PropertyDescriptor, invokedItem As PropertyValueUIItem)

參數

context
ITypeDescriptorContext

屬性的 ITypeDescriptorContext,與按兩下的圖示相關。

descriptor
PropertyDescriptor

與按兩下的圖示相關的屬性。

invokedItem
PropertyValueUIItem

PropertyValueUIItem,與按兩下的圖示相關。

範例

下列程式代碼範例會 PropertyValueUIItem 為名為 HorizontalMarginVerticalMargin之元件的任何屬性提供物件。 這些屬性的 會 PropertyValueUIItem 提供影像、工具提示和事件處理程式,可在單擊屬性的影像時顯示消息框。 此程式代碼範例是提供給 介面之較大範例的 IPropertyValueUIService 一部分。

// PropertyValueUIHandler delegate that provides PropertyValueUIItem
// objects to any properties named HorizontalMargin or VerticalMargin.
private void marginPropertyValueUIHandler(
    System.ComponentModel.ITypeDescriptorContext context,
    System.ComponentModel.PropertyDescriptor propDesc,
    ArrayList itemList)
{
    // A PropertyValueUIHandler added to the IPropertyValueUIService
    // is queried once for each property of a component and passed
    // a PropertyDescriptor that represents the characteristics of 
    // the property when the Properties window is set to a new 
    // component. A PropertyValueUIHandler can determine whether 
    // to add a PropertyValueUIItem for the object to its ValueUIItem 
    // list depending on the values of the PropertyDescriptor.
    if (propDesc.DisplayName.Equals("HorizontalMargin"))
    {
        Image img = Image.FromFile("SampImag.jpg");
        itemList.Add(new PropertyValueUIItem(img, new PropertyValueUIItemInvokeHandler(this.marginInvoke), "Test ToolTip"));
    }
    if (propDesc.DisplayName.Equals("VerticalMargin"))
    {
        Image img = Image.FromFile("SampImag.jpg");
        img.RotateFlip(RotateFlipType.Rotate90FlipNone);
        itemList.Add(new PropertyValueUIItem(img, new PropertyValueUIItemInvokeHandler(this.marginInvoke), "Test ToolTip"));
    }
}

備註

按兩下 屬性視窗中的圖示會引發InvokeHandler與圖示相關聯的事件PropertyValueUIItem。 事件 InvokeHandler 通常會啟動使用者介面 (UI) 來編輯屬性的值。 PropertyValueUIItemInvokeHandler將 加入 至 的 PropertyValueUIItem 屬性,InvokeHandler以指派事件處理程式,以在按兩下屬性名稱旁邊的圖示時執行適當的行為。

建立 PropertyValueUIItemInvokeHandler 委派時,必須識別處理事件的方法。 若要使事件與您的事件處理常式產生關聯,請將委派的執行個體 (Instance) 加入至事件。 除非您移除委派,否則每當事件發生時就會呼叫事件處理常式。 如需事件處理程式委派的詳細資訊,請參閱 處理和引發事件

擴充方法

GetMethodInfo(Delegate)

取得表示特定委派所代表之方法的物件。

適用於

另請參閱