public Form1() { InitializeComponent(); //AssignIconsToSquares(); LoadGame(16,16); } private void LoadGame(int rows, int cols) { TableLayoutPanel table = new TableLayoutPanel(); table.Dock = DockStyle.Fill; table.ColumnCount = cols; table.RowCount = rows; table.BackColor = Color.CornflowerBlue; for (int i = 0; i < rows; i++) { for (int j = 0; j < cols; j++) { Label label = new Label(); label.Dock = DockStyle.Fill; label.Name = "label" + i + "" + j; label.Text = "c"; label.BorderStyle = BorderStyle.Fixed3D; table.Controls.Add(label, i, j); table.AutoSize = true; } } this.Controls.Add(table); this.AutoScroll = true; this.HorizontalScroll.Enabled = true; this.VerticalScroll.Enabled = true; this.AutoSize = true; // this.HorizontalScroll table.RowStyles.Clear(); for (int i = 0; i < rows; i++) { table.RowStyles.Add(new RowStyle(SizeType.AutoSize)); } table.ColumnStyles.Clear(); for (int j = 0; j < cols; j++) { table.ColumnStyles.Add(new ColumnStyle(SizeType.AutoSize)); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)