0

I am making a simple Tic-Tac-Toe game. I want the line to cross both the pictureBox of a grid, and buttons. However I don't know how to make it, so that buttons are still clickable.

![transparent line]https://i.stack.imgur.com/jIcZS.jpg

![screenshot of a form]https://i.stack.imgur.com/gFPqn.jpg

  • [How to make two transparent layer with c#?](https://stackoverflow.com/a/36102074/3110834) or a couple of other similar answers. – Reza Aghaei Feb 10 '19 at 06:14
  • Since you're going to show a line only when the game ends, you could simply overlay the *board* with a transparent object, then remove this object when a new game begins. – Jimi Feb 10 '19 at 16:40

1 Answers1

0

Easiest way to do this is have a background that's a "grid" (all your lines), and add it as the background image of your form; then, simply add buttons to the form in the designer and place them in each "cell" in your "grid".

At the end of the game, you can add pieces of each line as the background image to each affected button, as well as change the form background to the same line - it will look like a single line, but still allow the buttons to be clickable.

There's a way to do this programmatically as well, but a bit more difficult with buttons - look into Control.CreateGraphics() method, to see how to draw with GDI+. More info here: https://learn.microsoft.com/en-us/dotnet/framework/winforms/advanced/how-to-create-graphics-objects-for-drawing

CoolBots
  • 4,770
  • 2
  • 16
  • 30