Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
140
BackColor of Images of OptionSet
posted

Hello

I have a ultraoptionset and fill the valuelist with a datasource.

The optinset has no imagelist-property so i set each item-image in a loop with

item.Appearance.Image = Image.FromHbitmap(((Bitmap)imlImageList16.Images["key"]).GetHbitmap(System.Drawing.Color.Magenta));

from a defined Imagelist

and i set

        optset.ImageTransparentColor = System.Drawing.Color.Magenta;

The Image is shown, but there is a blue background as you can see in the picture.

My ImageList-pictures are transparent with magenta. i use them for menu-icons too and there is no blue background.

What can i do?

Why is there no imagelist-property for the optionset?

Regards

Peter

 

 

  • 469350
    Suggested Answer
    Offline posted

    Hi Peter,

    I can't image where that blue is coming from. Perhaps the image transparency is being lost by Image.FromHBitmap.

    One thing you could try, though, is to give the image true transparency before you apply it, rather than using the ImageTransparentColor property. If you store the image in a Bitmap variable, there's a MakeTransparent method on that.

    If that does not help, then I recommend applying the same image to a PictureBox control, just as a test, to see what it looks like after you get it back from Image.FromHBitmap.

  • 69832
    Suggested Answer
    Offline posted

    I just verified that the control displays images properly when the ImageTransparentColor property is set; an image with a magenta background displayed the background transparently when the ImageTransparentColor property was set to that color. Going by the screenshot, it looks to me like blue is being assigned as the transparent color, i.e., maybe execution is traveling down some code path that you did not intend.

    I'm not sure why you are using the bitmap handles, since you can just assign the image like so:
    item.Appearance.Image = imlImageList16.Images["key"];

    I don't think that has any bearing on the transparency problem but you might want to check. If you like you can attach a sample project and we can take a look.