0

I'm trying to make my link label which is placed over a picture box to be transparent. Several things I have tried so far like.

Setting the linklabel's parent to picturecontrol and making the backcolor transparent

  this.linkLabel1.Parent = pictureBox1;
  this.linkLabel1.BackColor = System.Drawing.Color.Transparent;

Creating a subclass for my control and played with the ExStyle

public class TransparentLinkLabel : LinkLabel
{
  public TransparentLinkLabel()
  {
    this.SetStyle(ControlStyles.Opaque, true);
    this.SetStyle(ControlStyles.OptimizedDoubleBuffer, false);
  }
  protected override CreateParams CreateParams
  {
    get
    {
      CreateParams parms = base.CreateParams;
      parms.ExStyle |= 0x20;  // Turn on WS_EX_TRANSPARENT
      return parms;
    }
  }
}

So far no luck. Any further clues?

hypheni
  • 756
  • 3
  • 17
  • 37
  • look at my answer, I think it will solve your problem you just need to set the point text should be written and of course font and font color as you wish – Ashkan Mobayen Khiabani May 09 '15 at 12:54
  • Both a Label or a LinkLabe __will__ be transparent with just the two first lines in your question. No need to subclass, let alone drawstring anything! __Don't forget to set the linklabel.Location!!__ Here is a small detail about PictureBox: When you put a control on it, it will __not__ be added to its controls collection; so the initial loccation will be wrong. See [here](http://stackoverflow.com/questions/30066477/recover-previous-absolute-position-for-picturebox-when-parent-is-changed/30071783#30071783) for a handy function to let you design in the designer and make things work in code!! – TaW May 09 '15 at 12:57
  • Changing the Parent works just fine, you'll need to do a better job demonstrating your problem. Make a small repro project if necessary. – Hans Passant May 09 '15 at 12:58
  • Solved with the location trick along with parent set to picturebox. – hypheni May 09 '15 at 15:41

0 Answers0