A list of similar posts is referenced at the bottom of this reply.
This reply addresses pictureBoxes and Winforms (in the other posts below, several reiterate that WPF solves this well already)
- Create Winform
- Create x2 pictureBoxes
- foreground_pictureBox // picture box 'in front' of 'background'
- background_pictureBox // picture box 'behind' the 'foreground'
- Add the 'paint' event for each pictureBox
- select object in the 'designer'
- choose the 'properties' tab (or right-click and choose from popup menu)
- select the events button (small lightning bolt)
- double-click in the empty field to the right of the 'paint' event
- Add the following code to the main form's 'load' function (if not already added, use the approach in step 3 and select 'on load' rather than 'paint')
=
private void cFeedback_Form_Load(object sender, EventArgs e)
{
...
// Ensure that it is setup with transparent background
foreground_pictureBox.BackColor = Color.Transparent;
// Assign it's 'background'
foreground_pictureBox.Parent = background_pictureBox;
...
}
5 . In the 'paint' call for the 'background_pictureBox':
=
private void background_pictureBox_Paint(object sender, PaintEventArgs e)
{
...foreground_pictureBox_Paint(sender, e);
}
6 . Within the 'foreground_pictureBox_Paint' call, add in whatever graphics calls you want to be displayed in the foreground.
This topic repeats itself in several posts it seems:
how-to-make-picturebox-transparent
c-sharp-picturebox-transparent-background-doesnt-seem-to-work
make-overlapping-picturebox-transparent-in-c-net
a-picturebox-problem