语言

PropertyValueUIItemInvokeHandler 委托

定义

表示将处理 InvokeHandler 事件 PropertyValueUIItem的方法。

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或 HorizontalMargin. 的组件的任何属性提供一个VerticalMargin对象。 这些 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)

获取一个对象,该对象表示由指定委托表示的方法。

适用于

另请参阅