private void CreateBoard() { SuspendLayout(); var boardSize = new Size(CellSize * BoardRegion.Width + CellSize, CellSize * BoardRegion.Height + CellSize); base.MinimumSize = boardSize; base.MaximumSize = boardSize; CreateHeaders(); var points = BoardRegion.GetPoints(); foreach (var point in points) { BoardCell cell = new BoardCell(point.X, point.Y) { Top = point.X * CellSize + CellSize, Left = point.Y * CellSize + CellSize, Width = CellSize, Height = CellSize, }; cell.CellStateChanged(1); _cells[point.X, point.Y] = cell; cell.MouseDown += OnCellMouseDown; cell.DragEnter += OnCellDragEnter; cell.DragLeave += OnCellDragLeave; cell.DragDrop += OnCellDragDrop; cell.QueryContinueDrag += OnCellQueryContinueDrag; cell.Click += OnCellClick; Controls.Add(cell); } ResumeLayout(); }