title: My MessageBox.Show Code In C# Isn't Working. There Are No Errors But Something Is Wrong
body: <p>So I have recently been trying to learn C#, so I thought I'd try I simple project such as Tic-Tac-Toe. I am currently trying to add click functionality so to make sure it is working I put in a MessageBox.Show to make sure it new which area I was clicking. However, when I ran it no errors appeared and yet when I clicked on a box nothing happened. Does anyone know what is wrong with my code? Is it a problem with the MessageBox.Show code or with something else? Here is my code:</p>
  
  <p>In a Board.cs file I have:</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using System.Drawing;
  using System.Windows.Forms;
  
  namespace WindowsFormsApplication1
  {
      class Board
      {
          private Rectangle[,] slots = new Rectangle[3, 3];
          private Holder[,] holders = new Holder[3, 3];
  
          public const int X = 0;
          public const int O = 1;
          public const int B = 2;
  
          public void initBoard()
          {
              for (int x = 0; x &lt; 3; x++)
              {
                  for (int y = 0; y &lt; 3; y++)
                  {
                      slots[x, y] = new Rectangle(x * 167, y * 167, 167, 167);
                      holders[x, y] = new Holder();
                      holders[x, y].setValue(B);
                      holders[x, y].setLocation(new Point(x, y));
                  }
              }
          }
  
          public void detectHit(Point loc)
          {
              int x = 0;
              int y = 0;
  
              if (loc.X &lt; 167)
              {
                  x = 0;
              }
              else if (loc.X &gt; 167 &amp;&amp; loc.X &lt; 334)
              {
                  x = 1;
              }
              else if (loc.X &gt; 334)
              {
                  x = 2;
              }
              if (loc.Y &lt; 167)
              {
                  y = 0;
              }
              else if (loc.Y &gt; 167 &amp;&amp; loc.Y &lt; 334)
              {
                  y = 1;
              }
              else if (loc.Y &gt; 334 &amp;&amp; loc.Y &lt; 500)
              {
                  y = 2;
              }
  
              MessageBox.Show(x.ToString() + ", " + y.ToString() + "/n/n" + loc.ToString());
          }
      }
      class Holder
      {
          private Point location;
          private int value = Board.B;
          public void setLocation(Point p)
          {
              location = p;
          }
              public Point getLocation()
              {
                  return location;
              }
          public void setValue(int i)
          {
              value = i;
          }
          public int getValue()
          {
              return value;
          }
      }
  }
  </code></pre>
  
  <p>Then in my Form1.cs file I have:</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.ComponentModel;
  using System.Data;
  using System.Drawing;
  using System.Linq;
  using System.Text;
  using System.Windows.Forms;
  
  namespace WindowsFormsApplication1
  {
      public partial class Form1 : Form
      {
          GFX engine;
          Board theBoard;
  
          public Form1()
          {
              InitializeComponent();
          }
  
          private void panel1_Paint(object sender, PaintEventArgs e)
          {
              Graphics toPass = panel1.CreateGraphics();
              engine = new GFX(toPass);
  
              theBoard = new Board();
              theBoard.initBoard();
          }
  
          private void Form1_Click(object sender, EventArgs e)
          {
              Point mouse = Cursor.Position;
              mouse = panel1.PointToClient(mouse);
              theBoard.detectHit(mouse);
          }
      }
  }
  </code></pre>