private Point CoordinatesOfButton(Button[,] haystack,Button find) { int w = haystack.GetLength(0); // width int h = haystack.GetLength(1); // height for (int x = 0; x < w; ++x) { for (int y = 0; y < h; ++y) { if (haystack[x, y].Equals(find)) return new Point(x, y); } } return new Point(); }