PropertyValueUIItemInvokeHandler Delegasikan

Definisi

Mewakili metode yang akan menangani InvokeHandler peristiwa 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)

Parameter

context
ITypeDescriptorContext

ITypeDescriptorContext untuk properti yang terkait dengan ikon yang diklik dua kali.

descriptor
PropertyDescriptor

Properti yang terkait dengan ikon yang diklik dua kali.

invokedItem
PropertyValueUIItem

Yang PropertyValueUIItem terkait dengan ikon yang diklik dua kali.

Contoh

Contoh kode berikut menyediakan PropertyValueUIItem objek untuk properti komponen bernama HorizontalMargin atau VerticalMargin. PropertyValueUIItem untuk properti ini menyediakan gambar, TipsAlat, dan penanganan aktivitas yang menampilkan kotak pesan saat gambar untuk properti diklik. Contoh kode ini adalah bagian dari contoh yang lebih besar yang disediakan untuk IPropertyValueUIService antarmuka.

// 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"));
    }
}

Keterangan

Mengklik dua kali ikon di jendela Properti akan menaikkan InvokeHandler peristiwa PropertyValueUIItem yang terkait dengan ikon tersebut. Peristiwa ini InvokeHandler biasanya meluncurkan antarmuka pengguna (UI) untuk mengedit nilai properti. PropertyValueUIItemInvokeHandler Tambahkan ke InvokeHandler properti dari untuk PropertyValueUIItem menetapkan penanganan aktivitas untuk melakukan perilaku yang sesuai saat ikon yang ditampilkan di samping nama properti diklik ganda.

Saat membuat PropertyValueUIItemInvokeHandler delegasi, Anda mengidentifikasi metode yang akan menangani peristiwa. Untuk mengaitkan peristiwa dengan penanganan aktivitas Anda, tambahkan instans delegasi ke peristiwa. Penanganan aktivitas dipanggil setiap kali peristiwa terjadi, kecuali Jika Anda menghapus delegasi. Untuk informasi selengkapnya tentang delegasi penanganan aktivitas, lihat Menangani dan Meningkatkan Peristiwa.

Metode Ekstensi

GetMethodInfo(Delegate)

Mendapatkan objek yang mewakili metode yang diwakili oleh delegasi yang ditentukan.

Berlaku untuk

Lihat juga