ImageIndex

Ok I have a custom treeview

I've added more properties

    Public Property Table_ImageIndex() As Integer
        Get
            Return _TableIndex
        End Get
        Set(ByVal Value As Integer)
            _TableIndex = Value
        End Set
    End Property

The quesiton is this: I want to be able in the properybrowser to be able to set the image index of the image list like I do for the imageindex property. 

Ok the control as an imagelist and an imageindex propery already before I inherted it and added the propery above. Though currently in the properygrid I just get a number instead of being able to set the image using a little drop down like the imageindex propery has.

How do I duplicate the Imageindex propery behavior

Joe


Answer this question

ImageIndex

  • Philip Puffinburger

    Ok but this doesn't show the thumbnail of the image like the other ones do.

    Any idea how to get the thumbnail to show up in the property browser

    Joe

  • Mark Langan

    You must use the following converter and editor:
    <b>
    [Editor("System.Windows.Forms.Design.ImageIndexEditor", typeof(UITypeEditor))]
    [TypeConverter(typeof(ImageIndexConverter))]
    </b>

    This is an example from the SmartLibrary in C#

    <b>

    /// <summary>
    /// Internal store for "public int IconImageIndex"
    /// </summary>
    private int ixIconImageIndex = -1;
    /// <summary>
    /// Gets or sets the image list index value of the icon image displayed on the notification box.
    /// </summary>
    #if(Design_Time)
    [Category("Appearance")]
    [Description("Gets or sets the image list index value of the icon image displayed on the notification box.")]
    [Editor("System.Windows.Forms.Design.ImageIndexEditor", typeof(UITypeEditor))]
    [TypeConverter(typeof(ImageIndexConverter))]
    #endif
    public int IconImageIndex
    {
    get
    {
    return this.ixIconImageIndex;
    }
    set
    {
    this.ixIconImageIndex = value;
    }
    }

    #if(Design_Time)
    /// <summary>
    /// The default value for (IconImageIndex) is (-1).
    /// Prevent Microsoft Visual Studio.NET repeating that value again in the automatically generated source code.
    /// </summary>
    // <returns>True (generate code), false (don't generate code)</returns>
    private bool ShouldSerializeIconImageIndex()
    {
    return (this.ixIconImageIndex == -1)   false : true;
    }
    #endif

    </b>

  • ImageIndex