0

I'm doing the table game battleship, by moving pictures boxes with the mouse, the problem is that all the picture boxes that I have contain an image without background, but i have the problem that when I move it through different points, it shows a default background instead of showing the background of the "map". This messes the aspect of the game table.

I've tried this code in my program ,but it makes the ships default position is in the panel(which I do not want) and it doesn't solve the problem I described earlier (when you move ships over the others spaces)

Barco1.Parent = panel1;
Barco1.BackColor = Color.Transparent;

This is the program working, here we see that one of the ships is on the table but the background is the one from the form

An example of one of the ships

2 Answers2

0

picture box with transparent image

As you can see in the picture, there are:

  • Form with a BackgroundImage,
  • Panel with BackColor = Color.Transparent and BackgroundImage = some-image and
  • PictureBox with BackColor = Color.Transparent and an image as its Image property.

It should work for you.

Mohi
  • 1,776
  • 1
  • 26
  • 39
  • But here there no transition of backgrounds which is what happens when i'm moving it with the mouse throught different pictures boxes – Ivan Luque Garcia Nov 27 '18 at 21:18
  • So there is rendering problem. try double-buffer the objects as described in this post https://stackoverflow.com/a/220166/3764165 – Mohi Nov 28 '18 at 10:00
-1

It looks like You are setting the Image background as Transparent but You are adding that Image into another Panel!

Barco1.Parent = panel1;

So, Set the Background Color of the Panel1 as Transparent:

panel1.BackgroundColor=Color.Transparent;
N Subedi
  • 2,858
  • 2
  • 22
  • 36
  • I've tried this lines before, but it changes the origin point of the picture box, that without this line would be on the left of the panel but with that line it put it on the panel(which I really don't want) and also makes some weird when moving with the when running the programme – Ivan Luque Garcia Nov 27 '18 at 21:26