0

I want to add checkbox with transparent background to picturebox. I used code:

checkBox185.Parent = pictureBox1;
checkBox185.BackColor = Color.Transparent;

or:

pictureBox1.Controls.Add(checkBox185);
checkBox185.BackColor = Color.Transparent;

The problem is this "checkbox" disappears even when the back color is for example white. I added picture below: (The first two checkboxes are missing)

enter image description here

H H
  • 263,252
  • 30
  • 330
  • 514

1 Answers1

0

You need to update the Location of the control once its parent has been changed.

One way to do this is to convert the current location to screen coords and then back to client coords once the parent has been changed:

Point pt = this.PointToScreen(checkBox185.Location);
checkBox185.Parent = pictureBox1;
checkBox185.Location = pictureBox1.PointToClient(pt);   
checkBox185.BackColor = Color.Transparent;
Idle_Mind
  • 38,363
  • 3
  • 29
  • 40