JRS
JRS

Reputation: 1458

Make the background of a Label or LinkLabel transparent

Is it possible to make the background of a LinkLabel transparent?

Setting the BackColor to the Transparent system color does not work. Matching the BackColor of the container is not suitable because the container is an image.

Upvotes: 1

Views: 4385

Answers (1)

GentlemanCoder
GentlemanCoder

Reputation: 577

If your label lies on top of a picturebox or panel, you have to set the picturebox or panel as the label's parent in addition to setting .BackColor to Color.Transparent:

myLabel.Parent = myPicturebox;
myLabel.BackColor = Color.Transparent;

The reason for this is that Color.Transparent doesn't actually mean "transparent", it means "inherit the background color of your parent". And by default, the parent of your label is the form (or containing control), not the picturebox.

Upvotes: 2

Related Questions