I am making chess with c sharp and visual studio 2019. I managed to generate the chessboard with panels and I am planning to use PictureBox for the chess pieces. However, despite the chess images have a transparent background, it ignores the color of the panel and uses the default background color of the form. I suspect it is due to these lines.
...
Controls.Add(newPanel);
...
Controls.Add(picturebox);
...
What it is doing is adding each newly created panel to the form and adding the picturebox (which is used for showing a chess piece) to the form. I tried adding picturebox to the panel but the location of the picturebox becomes relative to that panel. When I drag the picturebox around (at runtime), the picturebox is not visible as soon as it leaves the panel. I have seen someone implemented this successfully before but I cannot figure out how.
This is what the background color looks like when moving the picturebox around (I have methods to handle mouse up, mouse down and mouse move). Any help would be appreciated.
CodePudding user response:
Drawing the shapes and putting them into a single control seems like the way to go. If I draw the grid and chess pieces instead of using controls, the background of the chess pieces show up correctly as transparent.