private void SetBtn(int x, int y, TableCell cell) { this.buttons[x, y]?.Dispose(); var btn = new CheckBox(); //btn.Image = cell.Image; btn.TextImageRelation = TextImageRelation.TextAboveImage; btn.BackgroundImage = cell.Image; btn.Width = this.CellWidth; btn.Height = this.CellHeight; this.buttons[x, y] = btn; btn.Top = XBorder + x * (CellHeight + CellXSpacing); btn.Left = YBorder + y * (CellWidth + CellYSpacing); btn.Appearance = Appearance.Button; btn.Click += (obj, args) => { CellClickEvent?.Invoke(obj, new TableCellClickEventArgs() { X = x, Y = y }); }; this.Controls.Add(btn); }