ImageBox transparent background color

Started by Deer2014, December 09, 2020, 04:45:23 PM

Previous topic - Next topic



Is it possible to set the ImageBox background color to transparent?
As with a standard .NET System.Windows.Forms.PictureBox.
Is this not supported?  :(


Richard Moss


This isn't something that is currently supported, although I raised an issue on the source repository to add this in a future update.

In the meantime, you could try creating your own custom control that inherits from ImageBox and turns on the correct style, then it will automatically paint correctly (if the BackColor property is set to Transparent) as I haven't overridden default background painting.

public class MyImageBox : Cyotek.Windows.Forms.ImageBox
  public MyImageBox()
      this.SetStyle(ControlStyles.SupportsTransparentBackColor, true);

I haven't fully tested this, but from a quick experiment changing the demonstration application it seems to work.

[attachment id=0 msg=1151]

Hope this helps.

Richard Moss
Read "Before You Post" before posting. Do not send me private messages. Do not expect instant replies.

All responses are hand crafted. No AI involved. Possibly no I either.