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

示例

下面的代码示例为名为 HorizontalMarginVerticalMargin的组件的任何属性提供了 一个 PropertyValueUIItem 对象。 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将 添加到 InvokeHandlerPropertyValueUIItem 属性,以分配事件处理程序,以在双击属性名称旁显示的图标时执行适当的行为。

创建 PropertyValueUIItemInvokeHandler 委托时,需要标识将处理该事件的方法。 若要将事件与事件处理程序关联,请将该委托的一个实例添加到事件中。 除非移除了该委托,否则每当发生该事件时就会调用事件处理程序。 有关事件处理程序委托的详细信息,请参阅 处理和引发事件

扩展方法

GetMethodInfo(Delegate)

获取指示指定委托表示的方法的对象。

适用于

另请参阅