private void GenerateTable(int columnCount, int rowCount) //Generar tabla con sus botones { //Clear out the existing controls, we are generating a new table layout tableLayoutPanel1.Controls.Clear(); //Clear out the existing row and column styles tableLayoutPanel1.ColumnStyles.Clear(); tableLayoutPanel1.RowStyles.Clear(); //Now we will generate the table, setting up the row and column counts first tableLayoutPanel1.ColumnCount = columnCount; tableLayoutPanel1.RowCount = rowCount; for (int x = 0; x < columnCount; x++) { //First add a column tableLayoutPanel1.ColumnStyles.Add(new ColumnStyle(SizeType.AutoSize)); for (int y = 0; y < rowCount; y++) { //Next, add a row. Only do this when once, when creating the first column if (x == 0) { tableLayoutPanel1.RowStyles.Add(new RowStyle(SizeType.AutoSize)); } //Create the control, in this case we will add a button BotonDobleTexto b = new BotonDobleTexto(); b.Height = 40; tableLayoutPanel1.Controls.Add(b, x, y); } } }
private void ColorearTablero() { List <Color> colores = GenerarColores(); Figura[] listaFiguras = f.GetListaFiguras(); int cont = 0; while (listaFiguras[cont] != null) { Ubicacion[] ubicaciones = listaFiguras[cont].GetLista(); int x = ubicaciones[0].GetX(); int y = ubicaciones[0].GetY(); BotonDobleTexto botonActual = (BotonDobleTexto)tableLayoutPanel1.GetControlFromPosition(x, y); tableLayoutPanel1.Controls.Remove(botonActual); BotonDobleTexto botonNuevo = new BotonDobleTexto(); if (listaFiguras[cont].GetTipo() != "solo") { botonNuevo.LeftText = listaFiguras[cont].GetNumMeta().ToString() + listaFiguras[cont].GetOperacion(); } botonNuevo.Height = 40; tableLayoutPanel1.Controls.Add(botonNuevo, x, y); foreach (Ubicacion ubicacion in ubicaciones) { tableLayoutPanel1.GetControlFromPosition(ubicacion.GetX(), ubicacion.GetY()).BackColor = colores.ElementAt(cont % 15); } cont++; } }