private static int RedistributePercents(int overlap, TableLayoutColumnStyleCollection styles, int[] column_widths) { int saved = 0; if (overlap > 0) { // Find the total percent (not always 100%) float total_percent = 0; foreach (ColumnStyle cs in styles) { if (cs.SizeType == SizeType.Percent) { total_percent += cs.Width; } } // Divvy up the space.. int index = 0; foreach (ColumnStyle cs in styles) { if (index >= column_widths.Length) { break; } if (cs.SizeType == SizeType.Percent) { int width_change = (int)((cs.Width / total_percent) * overlap); if (width_change > 0) { column_widths[index] += width_change; saved += width_change; } } index++; } } return(saved); }
void Gecis() { TableLayoutColumnStyleCollection styles = tableLayoutPanel1.ColumnStyles; int x = (listBox1.Size.Width + listBox2.Size.Width); int _x = this.Location.X + (listBox1.Size.Width + listBox2.Size.Width); if (gecisYedek == -1) { gecisYedek = styles[2].Width; minYedek = this.MinimumSize.Width; } if (gecis) { this.MinimumSize = new Size(minYedek, this.MinimumSize.Height); groupBox4.Visible = true; groupBox6.Visible = true; styles[2].Width = gecisYedek; styles[1].Width = gecisYedek; button4.Text = "<<"; } else { button4.Text = ">>"; this.MinimumSize = new Size(minYedek - x, this.MinimumSize.Height); groupBox4.Visible = false; groupBox6.Visible = false; this.Size = new Size(this.Size.Width - x, this.Size.Height); styles[2].Width = 0; styles[1].Width = 0; } gecis = !gecis; }
/// <summary> /// Clear controls and create a new boxplots. /// Also adjusts the table column size so it all scales well. /// </summary> public void CreateBoxPlots(List <StatisticModel> statisticList) { mainController.statisticView.chartTable.Controls.Clear(); //Value to set the ColumnCount int columns = 0; for (int index = 0; index < statisticList.Count; index++) { columns++; double lowerWhisker = statisticList[index].KleinsteWaarde; double upperWhisker = statisticList[index].GrootsteWaarde; double lowerBox = statisticList[index].EersteKwartiel; double upperBox = statisticList[index].DerdeKwartiel; double average = statisticList[index].Gemiddelde; double median = statisticList[index].Mediaan; BoxPlotModel boxPlot = new BoxPlotModel(lowerWhisker, upperWhisker, lowerBox, upperBox, average, median, distinctList[index]); mainController.statisticView.chartTable.Controls.Add(boxPlot); mainController.statisticView.chartTable.ColumnStyles.Add(new ColumnStyle()); } mainController.statisticView.chartTable.ColumnCount = columns; //Value used to calculate proper table scaling float percent = 100f / columns; TableLayoutColumnStyleCollection styles = mainController.statisticView.chartTable.ColumnStyles; foreach (ColumnStyle style in styles) { style.SizeType = SizeType.Percent; style.Width = percent; } }
private void CalculateColumnRowSizes (TableLayoutPanel panel, int columns, int rows) { TableLayoutSettings settings = panel.LayoutSettings; panel.column_widths = new int[panel.actual_positions.GetLength (0)]; panel.row_heights = new int[panel.actual_positions.GetLength (1)]; int border_width = TableLayoutPanel.GetCellBorderWidth (panel.CellBorderStyle); Rectangle parentDisplayRectangle = panel.DisplayRectangle; TableLayoutColumnStyleCollection col_styles = new TableLayoutColumnStyleCollection (panel); foreach (ColumnStyle cs in settings.ColumnStyles) col_styles.Add( new ColumnStyle(cs.SizeType, cs.Width)); TableLayoutRowStyleCollection row_styles = new TableLayoutRowStyleCollection (panel); foreach (RowStyle rs in settings.RowStyles) row_styles.Add (new RowStyle (rs.SizeType, rs.Height)); // If we have more columns than columnstyles, temporarily add enough columnstyles if (columns > col_styles.Count) { for (int i = col_styles.Count; i < columns; i++) col_styles.Add(new ColumnStyle()); } // Same for rows.. if (rows > row_styles.Count) { for (int i = row_styles.Count; i < rows; i++) row_styles.Add (new RowStyle ()); } while (row_styles.Count > rows) row_styles.RemoveAt (row_styles.Count - 1); while (col_styles.Count > columns) col_styles.RemoveAt (col_styles.Count - 1); // Figure up all the column widths int total_width = parentDisplayRectangle.Width - (border_width * (columns + 1)); int index = 0; // First assign all the Absolute sized columns.. foreach (ColumnStyle cs in col_styles) { if (cs.SizeType == SizeType.Absolute) { panel.column_widths[index] = (int)cs.Width; total_width -= (int)cs.Width; } index++; } index = 0; // Next, assign all the AutoSize columns.. foreach (ColumnStyle cs in col_styles) { if (cs.SizeType == SizeType.AutoSize) { int max_width = 0; // Find the widest control in the column for (int i = 0; i < rows; i ++) { Control c = panel.actual_positions[index, i]; if (c != null && c != dummy_control && c.VisibleInternal) { if (settings.GetColumnSpan (c) > 1) continue; if (c.AutoSize) max_width = Math.Max (max_width, c.PreferredSize.Width + c.Margin.Horizontal); else max_width = Math.Max (max_width, c.ExplicitBounds.Width + c.Margin.Horizontal); if (c.Width + c.Margin.Left + c.Margin.Right > max_width) max_width = c.Width + c.Margin.Left + c.Margin.Right; } } panel.column_widths[index] = max_width; total_width -= max_width; } index++; } index = 0; float total_percent = 0; // Finally, assign the remaining space to Percent columns.. if (total_width > 0) { int percent_width = total_width; // Find the total percent (not always 100%) foreach (ColumnStyle cs in col_styles) { if (cs.SizeType == SizeType.Percent) total_percent += cs.Width; } // Divy up the space.. foreach (ColumnStyle cs in col_styles) { if (cs.SizeType == SizeType.Percent) { panel.column_widths[index] = (int)((cs.Width / total_percent) * percent_width); total_width -= panel.column_widths[index]; } index++; } } if (total_width > 0) panel.column_widths[col_styles.Count - 1] += total_width; // Figure up all the row heights int total_height = parentDisplayRectangle.Height - (border_width * (rows + 1)); index = 0; // First assign all the Absolute sized rows.. foreach (RowStyle rs in row_styles) { if (rs.SizeType == SizeType.Absolute) { panel.row_heights[index] = (int)rs.Height; total_height -= (int)rs.Height; } index++; } index = 0; // Next, assign all the AutoSize rows.. foreach (RowStyle rs in row_styles) { if (rs.SizeType == SizeType.AutoSize) { int max_height = 0; // Find the tallest control in the row for (int i = 0; i < columns; i++) { Control c = panel.actual_positions[i, index]; if (c != null && c != dummy_control && c.VisibleInternal) { if (settings.GetRowSpan (c) > 1) continue; if (c.AutoSize) max_height = Math.Max (max_height, c.PreferredSize.Height + c.Margin.Vertical); else max_height = Math.Max (max_height, c.ExplicitBounds.Height + c.Margin.Vertical); if (c.Height + c.Margin.Top + c.Margin.Bottom > max_height) max_height = c.Height + c.Margin.Top + c.Margin.Bottom; } } panel.row_heights[index] = max_height; total_height -= max_height; } index++; } index = 0; total_percent = 0; // Finally, assign the remaining space to Percent columns.. if (total_height > 0) { int percent_height = total_height; // Find the total percent (not always 100%) foreach (RowStyle rs in row_styles) { if (rs.SizeType == SizeType.Percent) total_percent += rs.Height; } // Divy up the space.. foreach (RowStyle rs in row_styles) { if (rs.SizeType == SizeType.Percent) { panel.row_heights[index] = (int)((rs.Height / total_percent) * percent_height); total_height -= panel.row_heights[index]; } index++; } } if (total_height > 0) panel.row_heights[row_styles.Count - 1] += total_height; }
private void CalculateColumnRowSizes(TableLayoutPanel panel, int columns, int rows) { TableLayoutSettings settings = panel.LayoutSettings; panel.column_widths = new int[panel.actual_positions.GetLength(0)]; panel.row_heights = new int[panel.actual_positions.GetLength(1)]; int border_width = TableLayoutPanel.GetCellBorderWidth(panel.CellBorderStyle); Rectangle_ parentDisplayRectangle = panel.DisplayRectangle; TableLayoutColumnStyleCollection col_styles = new TableLayoutColumnStyleCollection(panel); foreach (ColumnStyle cs in settings.ColumnStyles) { col_styles.Add(new ColumnStyle(cs.SizeType, cs.Width)); } TableLayoutRowStyleCollection row_styles = new TableLayoutRowStyleCollection(panel); foreach (RowStyle rs in settings.RowStyles) { row_styles.Add(new RowStyle(rs.SizeType, rs.Height)); } // If we have more columns than columnstyles, temporarily add enough columnstyles if (columns > col_styles.Count) { for (int i = col_styles.Count; i < columns; i++) { col_styles.Add(new ColumnStyle()); } } // Same for rows.. if (rows > row_styles.Count) { for (int i = row_styles.Count; i < rows; i++) { row_styles.Add(new RowStyle()); } } while (row_styles.Count > rows) { row_styles.RemoveAt(row_styles.Count - 1); } while (col_styles.Count > columns) { col_styles.RemoveAt(col_styles.Count - 1); } // Find the largest column-span/row-span values. int max_colspan = 0, max_rowspan = 0; foreach (Control c in panel.Controls) { max_colspan = Math.Max(max_colspan, settings.GetColumnSpan(c)); max_rowspan = Math.Max(max_rowspan, settings.GetRowSpan(c)); } // Figure up all the column widths int total_width = parentDisplayRectangle.Width - (border_width * (columns + 1)); int index = 0; // First assign all the Absolute sized columns.. foreach (ColumnStyle cs in col_styles) { if (cs.SizeType == SizeType.Absolute) { panel.column_widths[index] = (int)cs.Width; total_width -= (int)cs.Width; } index++; } // Next, assign all the AutoSize columns to the width of their widest // control. If the table-layout is auto-sized, then make sure that // no column with Percent styling clips its contents. // (per http://msdn.microsoft.com/en-us/library/ms171690.aspx) for (int colspan = 0; colspan < max_colspan; ++colspan) { for (index = colspan; index < col_styles.Count - colspan; ++index) { ColumnStyle cs = col_styles[index]; if (cs.SizeType == SizeType.AutoSize || (panel.AutoSize && cs.SizeType == SizeType.Percent)) { int max_width = panel.column_widths[index]; // Find the widest control in the column for (int i = 0; i < rows; i++) { Control c = panel.actual_positions[index - colspan, i]; if (c != null && c != dummy_control && c.VisibleInternal) { // Skip any controls not being sized in this pass. if (settings.GetColumnSpan(c) != colspan + 1) { continue; } // Calculate the maximum control width. if (c.AutoSize) { max_width = Math.Max(max_width, c.PreferredSize.Width + c.Margin.Horizontal); } else { max_width = Math.Max(max_width, c.ExplicitBounds.Width + c.Margin.Horizontal); } max_width = Math.Max(max_width, c.Width + c.Margin.Left + c.Margin.Right); } } // Subtract the width of prior columns, if any. for (int i = Math.Max(index - colspan, 0); i < index; ++i) { max_width -= panel.column_widths[i]; } // If necessary, increase this column's width. if (max_width > panel.column_widths[index]) { max_width -= panel.column_widths[index]; panel.column_widths[index] += max_width; total_width -= max_width; } } } } index = 0; float total_percent = 0; // Finally, assign the remaining space to Percent columns, if any. if (total_width > 0) { int percent_width = total_width; // Find the total percent (not always 100%) foreach (ColumnStyle cs in col_styles) { if (cs.SizeType == SizeType.Percent) { total_percent += cs.Width; } } // Divvy up the space.. foreach (ColumnStyle cs in col_styles) { if (cs.SizeType == SizeType.Percent) { int width_change = (int)(((cs.Width / total_percent) * percent_width) - panel.column_widths[index]); if (width_change > 0) { panel.column_widths[index] += width_change; total_width -= width_change; } } index++; } } if (total_width > 0) { // Find the last column that isn't an Absolute SizeType, and give it // all this free space. (Absolute sized columns need to retain their // absolute width if at all possible!) int col = col_styles.Count - 1; for (; col >= 0; --col) { if (col_styles[col].SizeType != SizeType.Absolute) { break; } } if (col < 0) { col = col_styles.Count - 1; } panel.column_widths[col] += total_width; } // Figure up all the row heights int total_height = parentDisplayRectangle.Height - (border_width * (rows + 1)); index = 0; // First assign all the Absolute sized rows.. foreach (RowStyle rs in row_styles) { if (rs.SizeType == SizeType.Absolute) { panel.row_heights[index] = (int)rs.Height; total_height -= (int)rs.Height; } index++; } index = 0; // Next, assign all the AutoSize rows to the height of their tallest // control. If the table-layout is auto-sized, then make sure that // no row with Percent styling clips its contents. // (per http://msdn.microsoft.com/en-us/library/ms171690.aspx) for (int rowspan = 0; rowspan < max_rowspan; ++rowspan) { for (index = rowspan; index < row_styles.Count - rowspan; ++index) { RowStyle rs = row_styles[index]; if (rs.SizeType == SizeType.AutoSize || (panel.AutoSize && rs.SizeType == SizeType.Percent)) { int max_height = panel.row_heights[index]; // Find the tallest control in the row for (int i = 0; i < columns; i++) { Control c = panel.actual_positions[i, index - rowspan]; if (c != null && c != dummy_control && c.VisibleInternal) { // Skip any controls not being sized in this pass. if (settings.GetRowSpan(c) != rowspan + 1) { continue; } // Calculate the maximum control height. if (c.AutoSize) { max_height = Math.Max(max_height, c.PreferredSize.Height + c.Margin.Vertical); } else { max_height = Math.Max(max_height, c.ExplicitBounds.Height + c.Margin.Vertical); } max_height = Math.Max(max_height, c.Height + c.Margin.Top + c.Margin.Bottom); } } // Subtract the height of prior rows, if any. for (int i = Math.Max(index - rowspan, 0); i < index; ++i) { max_height -= panel.row_heights[i]; } // If necessary, increase this row's height. if (max_height > panel.row_heights[index]) { max_height -= panel.row_heights[index]; panel.row_heights[index] += max_height; total_height -= max_height; } } } } index = 0; total_percent = 0; // Finally, assign the remaining space to Percent rows, if any. if (total_height > 0) { int percent_height = total_height; // Find the total percent (not always 100%) foreach (RowStyle rs in row_styles) { if (rs.SizeType == SizeType.Percent) { total_percent += rs.Height; } } // Divvy up the space.. foreach (RowStyle rs in row_styles) { if (rs.SizeType == SizeType.Percent) { int height_change = (int)(((rs.Height / total_percent) * percent_height) - panel.row_heights[index]); if (height_change > 0) { panel.row_heights[index] += height_change; total_height -= height_change; } } index++; } } if (total_height > 0) { // Find the last row that isn't an Absolute SizeType, and give it // all this free space. (Absolute sized rows need to retain their // absolute height if at all possible!) int row = row_styles.Count - 1; for (; row >= 0; --row) { if (row_styles[row].SizeType != SizeType.Absolute) { break; } } if (row < 0) { row = row_styles.Count - 1; } panel.row_heights[row] += total_height; } }
private void ShowPersonTable(List <object> people) { Debug.WriteLine("ShowPersonTable"); individualsTableLayoutPanel.Size = new Size() { Height = 100, Width = individualsTableLayoutPanel.Width }; individualsTableLayoutPanel.AutoSize = true; individualsTableLayoutPanel.CellBorderStyle = TableLayoutPanelCellBorderStyle.Single; individualsTableLayoutPanel.ColumnCount = 0; individualsTableLayoutPanel.RowCount = 0; individualsTableLayoutPanel.ColumnCount = 6; individualsTableLayoutPanel.RowCount = 1; Debug.WriteLine(String.Format("Columns Styles Count: {0}", individualsTableLayoutPanel.ColumnStyles.Count)); TableLayoutColumnStyleCollection styles = individualsTableLayoutPanel.ColumnStyles; for (int i = styles.Count; i > 0; i--) { styles.RemoveAt(i - 1); } Debug.WriteLine(String.Format("Columns Styles Count: {0}", individualsTableLayoutPanel.ColumnStyles.Count)); individualsTableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.AutoSize)); //Coluna 1 com largura variavel individualsTableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.AutoSize)); //Coluna 2 com largura variavel individualsTableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.AutoSize)); //Coluna 3 com largura variavel individualsTableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 40F)); //Coluna 4 com largura fixa individualsTableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 40F)); //Coluna 5 com largura fixa individualsTableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 40F)); //Coluna 6 com largura fixa individualsTableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Absolute, 50F)); individualsTableLayoutPanel.Controls.Add(new TitleLabel("N.º Documento", AnchorStyles.Left), 0, 0); individualsTableLayoutPanel.Controls.Add(new TitleLabel("Primeiro Nome", AnchorStyles.Left), 1, 0); individualsTableLayoutPanel.Controls.Add(new TitleLabel("Apelido", AnchorStyles.Left), 2, 0); individualsTableLayoutPanel.Controls.Add(new TitleLabel("Tipo"), 3, 0); individualsTableLayoutPanel.Controls.Add(new TitleLabel("Ver"), 4, 0); individualsTableLayoutPanel.Controls.Add(new TitleLabel("Apagar"), 5, 0); foreach (object item in people) { individualsTableLayoutPanel.RowCount = individualsTableLayoutPanel.RowCount + 1; individualsTableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Absolute, 10F)); if (item is Person person) { if (person.IdDocuments.Count > 0) { individualsTableLayoutPanel.Controls.Add(new MyLabel(person.GetOneDocument(), AnchorStyles.Left), 0, individualsTableLayoutPanel.RowCount - 1); } else { individualsTableLayoutPanel.Controls.Add(new MyLabel("Sem Documentos", AnchorStyles.Left), 0, individualsTableLayoutPanel.RowCount - 1); } individualsTableLayoutPanel.Controls.Add(new MyLabel(person.FirstName, AnchorStyles.Left), 1, individualsTableLayoutPanel.RowCount - 1); individualsTableLayoutPanel.Controls.Add(new MyLabel(person.LastName, AnchorStyles.Left), 2, individualsTableLayoutPanel.RowCount - 1); if (person is Student) { PictureBox pictureBox = new PictureBox(); pictureBox.SizeMode = PictureBoxSizeMode.StretchImage; pictureBox.ClientSize = new Size(30, 30); pictureBox.Image = (Image) new Bitmap(JustiCal.Properties.Resources.cadetIco); individualsTableLayoutPanel.Controls.Add(pictureBox, 3, individualsTableLayoutPanel.RowCount - 1); } else if (person is Militar) { PictureBox pictureBox = new PictureBox(); pictureBox.SizeMode = PictureBoxSizeMode.StretchImage; pictureBox.ClientSize = new Size(30, 30); pictureBox.Image = (Image) new Bitmap(JustiCal.Properties.Resources.militaryIco1); individualsTableLayoutPanel.Controls.Add(pictureBox, 3, individualsTableLayoutPanel.RowCount - 1); } else { individualsTableLayoutPanel.Controls.Add(new Label() { Text = " " }, 3, individualsTableLayoutPanel.RowCount - 1); } ListIcon listIconWatch = new ListIcon(JustiCal.Properties.Resources.watchIco); listIconWatch.objectPassed = item; listIconWatch.Click += ListIconWatch_Click; individualsTableLayoutPanel.Controls.Add(listIconWatch, 4, individualsTableLayoutPanel.RowCount - 1); ListIcon listIconDelete = new ListIcon(JustiCal.Properties.Resources.deleteIco); listIconDelete.objectPassed = item; listIconDelete.Click += ListIconDelete_Click; individualsTableLayoutPanel.Controls.Add(listIconDelete, 5, individualsTableLayoutPanel.RowCount - 1); } if (item is Student) { } } }
private void CalculateColumnRowSizes(TableLayoutPanel panel, int columns, int rows) { TableLayoutSettings settings = panel.LayoutSettings; panel.column_widths = new int[panel.actual_positions.GetLength(0)]; panel.row_heights = new int[panel.actual_positions.GetLength(1)]; int border_width = TableLayoutPanel.GetCellBorderWidth(panel.CellBorderStyle); Rectangle parentDisplayRectangle = panel.DisplayRectangle; TableLayoutColumnStyleCollection col_styles = new TableLayoutColumnStyleCollection(panel); foreach (ColumnStyle cs in settings.ColumnStyles) { col_styles.Add(new ColumnStyle(cs.SizeType, cs.Width)); } TableLayoutRowStyleCollection row_styles = new TableLayoutRowStyleCollection(panel); foreach (RowStyle rs in settings.RowStyles) { row_styles.Add(new RowStyle(rs.SizeType, rs.Height)); } // If we have more columns than columnstyles, temporarily add enough columnstyles if (columns > col_styles.Count) { for (int i = col_styles.Count; i < columns; i++) { col_styles.Add(new ColumnStyle()); } } // Same for rows.. if (rows > row_styles.Count) { for (int i = row_styles.Count; i < rows; i++) { row_styles.Add(new RowStyle()); } } while (row_styles.Count > rows) { row_styles.RemoveAt(row_styles.Count - 1); } while (col_styles.Count > columns) { col_styles.RemoveAt(col_styles.Count - 1); } // Figure up all the column widths int total_width = parentDisplayRectangle.Width - (border_width * (columns + 1)); int index = 0; // First assign all the Absolute sized columns.. foreach (ColumnStyle cs in col_styles) { if (cs.SizeType == SizeType.Absolute) { panel.column_widths[index] = (int)cs.Width; total_width -= (int)cs.Width; } index++; } index = 0; // Next, assign all the AutoSize columns.. foreach (ColumnStyle cs in col_styles) { if (cs.SizeType == SizeType.AutoSize) { int max_width = 0; // Find the widest control in the column for (int i = 0; i < rows; i++) { Control c = panel.actual_positions[index, i]; if (c != null && c != dummy_control && c.VisibleInternal) { if (settings.GetColumnSpan(c) > 1) { continue; } if (c.AutoSize) { max_width = Math.Max(max_width, c.PreferredSize.Width + c.Margin.Horizontal); } else { max_width = Math.Max(max_width, c.ExplicitBounds.Width + c.Margin.Horizontal); } if (c.Width + c.Margin.Left + c.Margin.Right > max_width) { max_width = c.Width + c.Margin.Left + c.Margin.Right; } } } panel.column_widths[index] = max_width; total_width -= max_width; } index++; } index = 0; float total_percent = 0; // Finally, assign the remaining space to Percent columns.. if (total_width > 0) { int percent_width = total_width; // Find the total percent (not always 100%) foreach (ColumnStyle cs in col_styles) { if (cs.SizeType == SizeType.Percent) { total_percent += cs.Width; } } // Divy up the space.. foreach (ColumnStyle cs in col_styles) { if (cs.SizeType == SizeType.Percent) { panel.column_widths[index] = (int)((cs.Width / total_percent) * percent_width); total_width -= panel.column_widths[index]; } index++; } } if (total_width > 0) { panel.column_widths[col_styles.Count - 1] += total_width; } // Figure up all the row heights int total_height = parentDisplayRectangle.Height - (border_width * (rows + 1)); index = 0; // First assign all the Absolute sized rows.. foreach (RowStyle rs in row_styles) { if (rs.SizeType == SizeType.Absolute) { panel.row_heights[index] = (int)rs.Height; total_height -= (int)rs.Height; } index++; } index = 0; // Next, assign all the AutoSize rows.. foreach (RowStyle rs in row_styles) { if (rs.SizeType == SizeType.AutoSize) { int max_height = 0; // Find the tallest control in the row for (int i = 0; i < columns; i++) { Control c = panel.actual_positions[i, index]; if (c != null && c != dummy_control && c.VisibleInternal) { if (settings.GetRowSpan(c) > 1) { continue; } if (c.AutoSize) { max_height = Math.Max(max_height, c.PreferredSize.Height + c.Margin.Vertical); } else { max_height = Math.Max(max_height, c.ExplicitBounds.Height + c.Margin.Vertical); } if (c.Height + c.Margin.Top + c.Margin.Bottom > max_height) { max_height = c.Height + c.Margin.Top + c.Margin.Bottom; } } } panel.row_heights[index] = max_height; total_height -= max_height; } index++; } index = 0; total_percent = 0; // Finally, assign the remaining space to Percent columns.. if (total_height > 0) { int percent_height = total_height; // Find the total percent (not always 100%) foreach (RowStyle rs in row_styles) { if (rs.SizeType == SizeType.Percent) { total_percent += rs.Height; } } // Divy up the space.. foreach (RowStyle rs in row_styles) { if (rs.SizeType == SizeType.Percent) { panel.row_heights[index] = (int)((rs.Height / total_percent) * percent_height); total_height -= panel.row_heights[index]; } index++; } } if (total_height > 0) { panel.row_heights[row_styles.Count - 1] += total_height; } }
private void Form1_Load(object sender, EventArgs e) { rowStyles = tableLayoutPanel1.RowStyles; columnStyles = tableLayoutPanel1.ColumnStyles; }
private void InitializeTable() { tableLayoutPanel1.Visible = true; //显示边界 tableLayoutPanel1.CellBorderStyle = TableLayoutPanelCellBorderStyle.Single; //考虑到tableLayoutPanel1.GrowStyle,每次刷新前清除control tableLayoutPanel1.Controls.Clear(); //显示行=5,列=5 tableLayoutPanel1.RowCount = nameList.Count + 1; tableLayoutPanel1.ColumnCount = 3; #region 行和列大小一致 TableLayoutColumnStyleCollection cols = tableLayoutPanel1.ColumnStyles; // for (int i = 0; i < cols.Count; i++) // { // cols[i].SizeType = SizeType.Absolute; // cols[i].Width = 100 / cols.Count; // } TableLayoutRowStyleCollection rows = tableLayoutPanel1.RowStyles; for (int i = 0; i < rows.Count; i++) { rows[i].SizeType = SizeType.Absolute; rows[i].Height = 15; } #endregion //为每个Cell添加一个控件。 for (int i = 0; i < tableLayoutPanel1.ColumnCount; i++) { for (int j = 0; j < tableLayoutPanel1.RowCount; j++) { Label label = new Label(); label.AutoSize = true; label.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right))); if (j == 0 && i == 0) { label.Text = "文件名称"; tableLayoutPanel1.Controls.Add(label, i, j); } if (j == 0 && i == 1) { label.Text = "音频时长"; tableLayoutPanel1.Controls.Add(label, i, j); } if (j == 0 && i == 2) { label.Text = "延长时间(s)"; tableLayoutPanel1.Controls.Add(label, i, j); } if (i == 0 && j != 0) //文件名称 { label.Text = nameList[j - 1]; tableLayoutPanel1.Controls.Add(label, i, j); } else if (i == 1 && j != 0) //音频时长 { label.Text = durationList[j - 1]; tableLayoutPanel1.Controls.Add(label, i, j); } else if (i == 2 && j != 0) //延长时长 { TextBox textBox = new TextBox(); textBox.Text = "0"; textBox.Name = "textBox_" + j.ToString(); tableLayoutPanel1.Controls.Add(textBox, i, j); } } } //设置大小 // tableLayoutPanel1.Size = new Size(600, 400); tableLayoutPanel1.Update(); }
private static void CalculateColumnWidths(TableLayoutSettings settings, Control[,] actual_positions, int max_colspan, TableLayoutColumnStyleCollection col_styles, bool auto_size, int[] column_widths, bool minimum_sizes) { Size proposed_size = minimum_sizes ? new Size(1, 0) : Size.Empty; int rows = actual_positions.GetLength(1); float max_percent_size = 0; // First assign all the Absolute sized columns int index = 0; foreach (ColumnStyle cs in col_styles) { if (index >= column_widths.Length) { break; } if (cs.SizeType == SizeType.Absolute) { column_widths[index] = (int)cs.Width; } index++; } while (index < column_widths.Length) { column_widths[index] = 0; index++; } // Next, assign all the AutoSize columns to the width of their widest // control. If the table-layout is auto-sized, then make sure that // no column with Percent styling clips its contents. // (per http://msdn.microsoft.com/en-us/library/ms171690.aspx) for (int colspan = 0; colspan < max_colspan; ++colspan) { for (index = colspan; index < column_widths.Length - colspan; ++index) { ColumnStyle cs = index < col_styles.Count ? col_styles[index] : default_column_style; if (cs.SizeType == SizeType.AutoSize || (auto_size && cs.SizeType == SizeType.Percent)) { int max_width = column_widths[index]; // Find the widest control in the column for (int i = 0; i < rows; i++) { Control c = actual_positions[index - colspan, i]; if (c != null && c != dummy_control && c.VisibleInternal) { // Skip any controls not being sized in this pass. if (settings.GetColumnSpan(c) != colspan + 1) { continue; } // Calculate the maximum control width. max_width = Math.Max(max_width, GetControlSize(c, proposed_size).Width + c.Margin.Horizontal); } } if (cs.SizeType == SizeType.Percent) { max_percent_size = Math.Max(max_percent_size, max_width / cs.Width); } // Subtract the width of prior columns, if any. for (int i = Math.Max(index - colspan, 0); i < index; ++i) { max_width -= column_widths[i]; } // If necessary, increase this column's width. if (max_width > column_widths[index]) { column_widths[index] = max_width; } } } } for (index = 0; index < col_styles.Count && index < column_widths.Length; ++index) { ColumnStyle cs = col_styles[index]; if (cs.SizeType == SizeType.Percent) { column_widths[index] = Math.Max(column_widths[index], (int)Math.Ceiling(max_percent_size * cs.Width)); } } }
private void btnGenerateMatrixSLAE_Click(object sender, EventArgs e) { //генерируем матрицу СЛАУ MatrixA = new NumericUpDown[CntVariables, CntVariables]; ResultB = new NumericUpDown[CntVariables]; //создаем контрол табличного размещения //ширина и высота равны ширине и высоте основной панели TableLayoutPanel tableLayoutPanel = new TableLayoutPanel() { Width = panelMatrixSLAE.Width, Height = panelMatrixSLAE.Height, Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Bottom, AutoScroll = true, CellBorderStyle = TableLayoutPanelCellBorderStyle.Inset }; //Стили колонок и строк TableLayoutColumnStyleCollection csc = tableLayoutPanel.ColumnStyles; TableLayoutRowStyleCollection rsc = tableLayoutPanel.RowStyles; tableLayoutPanel.ColumnCount = CntVariables + 1; //кол-во колонок = размер матрицы + столбец для результатов tableLayoutPanel.RowCount = CntVariables + 2; //кол-во строк = размер матрицы + строка для заголовка + строка для кнопки расчета //создаем и вставляем заголовок для матрицы Label labelMatrixA = new Label() { Text = "Матрица А", AutoSize = true, Dock = DockStyle.Fill, TextAlign = ContentAlignment.TopCenter }; tableLayoutPanel.Controls.Add(labelMatrixA, 0, 0); tableLayoutPanel.SetColumnSpan(labelMatrixA, CntVariables); //для заголовка стили размеров автоматические csc.Add(new ColumnStyle(SizeType.Percent, 100f / (CntVariables + 1))); rsc.Add(new ColumnStyle(SizeType.AutoSize)); int tabIndex = 0;//проставляем TabIndex //создаем контролы для матрицы СЛАУ for (int r = 0; r < CntVariables; r++) { csc.Add(new ColumnStyle(SizeType.Percent, 100f / (CntVariables + 1))); for (int c = 0; c < CntVariables; c++) { MatrixA[r, c] = CreateNumericUpDown(tabIndex++); MatrixA[r, c].Name = string.Format(matrixItemName, r, c); if (r != c) // Для быстрого заполнения симметричной матрицы добавляем событие отзеркаливания значения при его изменении { MatrixA[r, c].ValueChanged += NumericValueChanged_HelpFillSymmetricMatrix; } tableLayoutPanel.Controls.Add(MatrixA[r, c], c, r + 1); } tabIndex++; } //создаем и втсавляем заголовок для результатов Label labelResultB = new Label() { Text = "Результат B", AutoSize = true, Dock = DockStyle.Fill, TextAlign = ContentAlignment.TopCenter }; tableLayoutPanel.Controls.Add(labelResultB, CntVariables, 0); //добавляем контролы результатов tabIndex = -1; for (int i = 0; i < CntVariables; i++) { ResultB[i] = CreateNumericUpDown(tabIndex += CntVariables + 1, Color.LightBlue); rsc.Add(new ColumnStyle(SizeType.Percent, 100f / (CntVariables + 1))); tableLayoutPanel.Controls.Add(ResultB[i], CntVariables, i + 1); } //создаем кнопку для расчета СЛАУ и вставляем в контрол табличного размещения Button btnCalc = new Button() { Text = "Решить", Anchor = AnchorStyles.None, Dock = DockStyle.Fill, AutoSize = true }; btnCalc.Click += BtnCalc_Click; tableLayoutPanel.Controls.Add(btnCalc, 0, tableLayoutPanel.RowCount - 1); tableLayoutPanel.SetColumnSpan(btnCalc, tableLayoutPanel.ColumnCount); panelMatrixSLAE.Controls.Clear(); //очищаем панель panelMatrixSLAE.Controls.Add(tableLayoutPanel); // вставляем матрицу СЛАУ MatrixA[0, 0].Focus(); //делаем активным первый элемент в матрице }
private void SortingResult_Load(object sender, EventArgs e) { this.WindowState = FormWindowState.Maximized; this.FormBorderStyle = FormBorderStyle.FixedSingle; beforeSortingPanel.Height = afterSortingPanel.Height = (int)(this.Height * 0.34); beforeSortingPanel.Width = afterSortingPanel.Width = beforeSortingPanel.Height * 5; beforeSortingPanel.Location = new Point((int)(this.Width * 0.01), (int)(this.Height * 0.1)); afterSortingPanel.Location = new Point((int)(this.Width * 0.01), (int)(this.Height * 0.57)); beforeSortingHint.Location = new Point((int)((beforeSortingPanel.Width - beforeSortingHint.Width) / 2 + beforeSortingPanel.Location.X), (int)(this.Height * 0.05)); afterSortingHint.Location = new Point((int)((beforeSortingPanel.Width - beforeSortingHint.Width) / 2 + beforeSortingPanel.Location.X), (int)(this.Height * 0.52)); TableLayoutColumnStyleCollection columnstyles = beforeSortingPanel.ColumnStyles; foreach (ColumnStyle style in columnstyles) { style.SizeType = SizeType.Absolute; style.Width = beforeSortingPanel.Height; } columnstyles = afterSortingPanel.ColumnStyles; foreach (ColumnStyle style in columnstyles) { style.SizeType = SizeType.Absolute; style.Width = afterSortingPanel.Height; } if (_path != null) { picturePanel p = new picturePanel(); p.init(MainInfo.picInfo[_path].image, MainInfo.picInfo[_path].name); p.image_name.Font = new Font("微软雅黑", 17); p.image_name.Height = 32; } if (_path == null) { originPicList = new string[picNum]; for (int i = 0; i < picNum; i++) { picturePanel p = new picturePanel(i); beforeSortingPanel.ColumnStyles.Insert(beforeSortingPanel.ColumnCount++, new ColumnStyle(SizeType.Absolute, beforeSortingPanel.Height)); beforeSortingPanel.Controls.Add(p, i, 0); p.init(MainInfo.picInfo[originArray[i].path].image, originArray[i].name); p.image_name.Height = 25; p.image_name.Font = new Font("微软雅黑", 13); p.DoubleClick += origin_e1; ((PictureBox)(p.Controls[0])).DoubleClick += origin_e2; ((Label)(p.Controls[1])).DoubleClick += origin_e3; originPicList[i] = originArray[i].path; } sortedPicList = new string[picNum]; for (int i = 0; i < picNum; i++) { picturePanel p = new picturePanel(i); afterSortingPanel.ColumnStyles.Insert(afterSortingPanel.ColumnCount++, new ColumnStyle(SizeType.Absolute, afterSortingPanel.Height)); afterSortingPanel.Controls.Add(p, i, 0); p.init(MainInfo.picInfo[sortedArray[i].path].image, sortedArray[i].name); p.image_name.Height = 25; p.image_name.Font = new Font("微软雅黑", 13); p.DoubleClick += sorted_e1; ((PictureBox)(p.Controls[0])).DoubleClick += sorted_e2; ((Label)(p.Controls[1])).DoubleClick += sorted_e3; sortedPicList[i] = sortedArray[i].path; } } else { originPicList = new string[picNum + 1]; picturePanel pp = new picturePanel(0); beforeSortingPanel.ColumnStyles.Insert(beforeSortingPanel.ColumnCount++, new ColumnStyle(SizeType.Absolute, beforeSortingPanel.Height)); beforeSortingPanel.Controls.Add(pp, 0, 0); pp.init(MainInfo.picInfo[_path].image, "参考图像"); pp.image_name.Height = 25; pp.image_name.Font = new Font("微软雅黑", 13); pp.DoubleClick += origin_e1; pp.BackColor = Color.Gray; ((PictureBox)(pp.Controls[0])).DoubleClick += origin_e2; ((Label)(pp.Controls[1])).DoubleClick += origin_e3; originPicList[0] = _path; for (int i = 0; i < picNum; i++) { picturePanel p = new picturePanel(i + 1); beforeSortingPanel.ColumnStyles.Insert(beforeSortingPanel.ColumnCount++, new ColumnStyle(SizeType.Absolute, beforeSortingPanel.Height)); beforeSortingPanel.Controls.Add(p, i + 1, 0); p.init(MainInfo.picInfo[originArray[i].path].image, originArray[i].name); p.image_name.Height = 25; p.image_name.Font = new Font("微软雅黑", 13); p.DoubleClick += origin_e1; ((PictureBox)(p.Controls[0])).DoubleClick += origin_e2; ((Label)(p.Controls[1])).DoubleClick += origin_e3; originPicList[i + 1] = originArray[i].path; } sortedPicList = new string[picNum + 1]; picturePanel ppp = new picturePanel(0); afterSortingPanel.ColumnStyles.Insert(afterSortingPanel.ColumnCount++, new ColumnStyle(SizeType.Absolute, afterSortingPanel.Height)); afterSortingPanel.Controls.Add(ppp, 0, 0); ppp.init(MainInfo.picInfo[_path].image, "参考图像"); ppp.image_name.Height = 25; ppp.image_name.Font = new Font("微软雅黑", 13); ppp.DoubleClick += sorted_e1; ppp.BackColor = Color.Gray; ((PictureBox)(ppp.Controls[0])).DoubleClick += sorted_e2; ((Label)(ppp.Controls[1])).DoubleClick += sorted_e3; sortedPicList[0] = _path; for (int i = 0; i < picNum; i++) { picturePanel p = new picturePanel(i + 1); afterSortingPanel.ColumnStyles.Insert(afterSortingPanel.ColumnCount++, new ColumnStyle(SizeType.Absolute, afterSortingPanel.Height)); afterSortingPanel.Controls.Add(p, i + 1, 0); p.init(MainInfo.picInfo[sortedArray[i].path].image, sortedArray[i].name); p.image_name.Height = 25; p.image_name.Font = new Font("微软雅黑", 13); p.DoubleClick += sorted_e1; ((PictureBox)(p.Controls[0])).DoubleClick += sorted_e2; ((Label)(p.Controls[1])).DoubleClick += sorted_e3; sortedPicList[i + 1] = sortedArray[i].path; } } }
public TableLayoutColumnStyleCollectionWrapper(TableLayoutColumnStyleCollection columnStyles) { _columnStyles = columnStyles; }
public void separacion(ref List <double> nNum, ref double fe) { if (Convert.ToInt32(textBox1.Text) < 12) { tableLayoutPanel1.AutoScroll = false; } else { tableLayoutPanel1.AutoScroll = true; } tableLayoutPanel1.Controls.Clear(); int n = Convert.ToInt32(textBox1.Text); tableLayoutPanel1.ColumnCount = n; TableLayoutColumnStyleCollection styles = this.tableLayoutPanel1.ColumnStyles; foreach (ColumnStyle style in styles) { style.SizeType = SizeType.Percent; style.Width = 100 / n; } List <rango> nRang = new List <rango>(); for (int i = 0; i < n; i++) { rango r = new rango(); Label lb = new Label(); lb.Text = fe.ToString(); Label lab = new Label(); Label cont = new Label(); int valor = Convert.ToInt32(textBox5.Text); r.min = Math.Round((((i) * fe) / valor), 3); r.max = Math.Round((((i + 1) * fe) / valor), 3); lab.Text = r.min.ToString() + " - " + r.max.ToString(); cont.Text = "0"; tableLayoutPanel1.Controls.Add(lb, i, 0); tableLayoutPanel1.Controls.Add(lab, i, 2); tableLayoutPanel1.Controls.Add(cont, i, 1); nRang.Add(r); } foreach (var y in nNum) { for (int i = 0; i < nRang.Count; i++) { if (nRang[i].min <= y && y < nRang[i].max) { Label lab = (Label)tableLayoutPanel1.GetControlFromPosition(i, 1); lab.Text = (Convert.ToInt32(lab.Text) + 1).ToString(); } } } label3.Text = nNum.Count.ToString(); List <sumatoria> nSum = new List <sumatoria>(); double storia = 0; for (int i = 0; i < tableLayoutPanel1.ColumnCount; i++) { Label lb = (Label)tableLayoutPanel1.GetControlFromPosition(i, 1); sumatoria s = new sumatoria(); s.fo = Convert.ToDouble(lb.Text); nSum.Add(s); s.r = s.fo - fe; s.r = s.r * s.r; storia += s.r; } storia = (1.00 / fe) * storia; storia = Math.Round(storia, 5); textBox3.Text = storia.ToString(); }
private void CalculateColumnRowSizes (TableLayoutPanel panel, int columns, int rows) { TableLayoutSettings settings = panel.LayoutSettings; panel.column_widths = new int[panel.actual_positions.GetLength (0)]; panel.row_heights = new int[panel.actual_positions.GetLength (1)]; int border_width = TableLayoutPanel.GetCellBorderWidth (panel.CellBorderStyle); Rectangle parentDisplayRectangle = panel.DisplayRectangle; TableLayoutColumnStyleCollection col_styles = new TableLayoutColumnStyleCollection (panel); foreach (ColumnStyle cs in settings.ColumnStyles) col_styles.Add( new ColumnStyle(cs.SizeType, cs.Width)); TableLayoutRowStyleCollection row_styles = new TableLayoutRowStyleCollection (panel); foreach (RowStyle rs in settings.RowStyles) row_styles.Add (new RowStyle (rs.SizeType, rs.Height)); // If we have more columns than columnstyles, temporarily add enough columnstyles if (columns > col_styles.Count) { for (int i = col_styles.Count; i < columns; i++) col_styles.Add(new ColumnStyle()); } // Same for rows.. if (rows > row_styles.Count) { for (int i = row_styles.Count; i < rows; i++) row_styles.Add (new RowStyle ()); } while (row_styles.Count > rows) row_styles.RemoveAt (row_styles.Count - 1); while (col_styles.Count > columns) col_styles.RemoveAt (col_styles.Count - 1); // Find the largest column-span/row-span values. int max_colspan = 0, max_rowspan = 0; foreach (Control c in panel.Controls) { max_colspan = Math.Max (max_colspan, settings.GetColumnSpan (c)); max_rowspan = Math.Max (max_rowspan, settings.GetRowSpan (c)); } // Figure up all the column widths int total_width = parentDisplayRectangle.Width - (border_width * (columns + 1)); int index = 0; // First assign all the Absolute sized columns.. foreach (ColumnStyle cs in col_styles) { if (cs.SizeType == SizeType.Absolute) { panel.column_widths[index] = (int)cs.Width; total_width -= (int)cs.Width; } index++; } // Next, assign all the AutoSize columns to the width of their widest // control. If the table-layout is auto-sized, then make sure that // no column with Percent styling clips its contents. // (per http://msdn.microsoft.com/en-us/library/ms171690.aspx) for (int colspan = 0; colspan < max_colspan; ++colspan) { for (index = colspan; index < col_styles.Count - colspan; ++index) { ColumnStyle cs = col_styles[index]; if (cs.SizeType == SizeType.AutoSize || (panel.AutoSize && cs.SizeType == SizeType.Percent)) { int max_width = panel.column_widths[index]; // Find the widest control in the column for (int i = 0; i < rows; i ++) { Control c = panel.actual_positions[index - colspan, i]; if (c != null && c != dummy_control && c.VisibleInternal) { // Skip any controls not being sized in this pass. if (settings.GetColumnSpan (c) != colspan + 1) continue; // Calculate the maximum control width. if (c.AutoSize) max_width = Math.Max (max_width, c.PreferredSize.Width + c.Margin.Horizontal); else max_width = Math.Max (max_width, c.ExplicitBounds.Width + c.Margin.Horizontal); max_width = Math.Max (max_width, c.Width + c.Margin.Left + c.Margin.Right); } } // Subtract the width of prior columns, if any. for (int i = Math.Max (index - colspan, 0); i < index; ++i) max_width -= panel.column_widths[i]; // If necessary, increase this column's width. if (max_width > panel.column_widths[index]) { max_width -= panel.column_widths[index]; panel.column_widths[index] += max_width; total_width -= max_width; } } } } index = 0; float total_percent = 0; // Finally, assign the remaining space to Percent columns, if any. if (total_width > 0) { int percent_width = total_width; // Find the total percent (not always 100%) foreach (ColumnStyle cs in col_styles) { if (cs.SizeType == SizeType.Percent) total_percent += cs.Width; } // Divvy up the space.. foreach (ColumnStyle cs in col_styles) { if (cs.SizeType == SizeType.Percent) { int width_change = (int)(((cs.Width / total_percent) * percent_width) - panel.column_widths[index]); if (width_change > 0) { panel.column_widths[index] += width_change; total_width -= width_change; } } index++; } } if (total_width > 0) { // Find the last column that isn't an Absolute SizeType, and give it // all this free space. (Absolute sized columns need to retain their // absolute width if at all possible!) int col = col_styles.Count - 1; for (; col >= 0; --col) { if (col_styles[col].SizeType != SizeType.Absolute) break; } if (col < 0) col = col_styles.Count - 1; panel.column_widths[col] += total_width; } // Figure up all the row heights int total_height = parentDisplayRectangle.Height - (border_width * (rows + 1)); index = 0; // First assign all the Absolute sized rows.. foreach (RowStyle rs in row_styles) { if (rs.SizeType == SizeType.Absolute) { panel.row_heights[index] = (int)rs.Height; total_height -= (int)rs.Height; } index++; } index = 0; // Next, assign all the AutoSize rows to the height of their tallest // control. If the table-layout is auto-sized, then make sure that // no row with Percent styling clips its contents. // (per http://msdn.microsoft.com/en-us/library/ms171690.aspx) for (int rowspan = 0; rowspan < max_rowspan; ++rowspan) { for (index = rowspan; index < row_styles.Count - rowspan; ++index) { RowStyle rs = row_styles[index]; if (rs.SizeType == SizeType.AutoSize || (panel.AutoSize && rs.SizeType == SizeType.Percent)) { int max_height = panel.row_heights[index]; // Find the tallest control in the row for (int i = 0; i < columns; i++) { Control c = panel.actual_positions[i, index - rowspan]; if (c != null && c != dummy_control && c.VisibleInternal) { // Skip any controls not being sized in this pass. if (settings.GetRowSpan (c) != rowspan + 1) continue; // Calculate the maximum control height. if (c.AutoSize) max_height = Math.Max (max_height, c.PreferredSize.Height + c.Margin.Vertical); else max_height = Math.Max (max_height, c.ExplicitBounds.Height + c.Margin.Vertical); max_height = Math.Max (max_height, c.Height + c.Margin.Top + c.Margin.Bottom); } } // Subtract the height of prior rows, if any. for (int i = Math.Max (index - rowspan, 0); i < index; ++i) max_height -= panel.row_heights[i]; // If necessary, increase this row's height. if (max_height > panel.row_heights[index]) { max_height -= panel.row_heights[index]; panel.row_heights[index] += max_height; total_height -= max_height; } } } } index = 0; total_percent = 0; // Finally, assign the remaining space to Percent rows, if any. if (total_height > 0) { int percent_height = total_height; // Find the total percent (not always 100%) foreach (RowStyle rs in row_styles) { if (rs.SizeType == SizeType.Percent) total_percent += rs.Height; } // Divvy up the space.. foreach (RowStyle rs in row_styles) { if (rs.SizeType == SizeType.Percent) { int height_change = (int)(((rs.Height / total_percent) * percent_height) - panel.row_heights[index]); if (height_change > 0) { panel.row_heights[index] += height_change; total_height -= height_change; } } index++; } } if (total_height > 0) { // Find the last row that isn't an Absolute SizeType, and give it // all this free space. (Absolute sized rows need to retain their // absolute height if at all possible!) int row = row_styles.Count - 1; for (; row >= 0; --row) { if (row_styles[row].SizeType != SizeType.Absolute) break; } if (row < 0) row = row_styles.Count - 1; panel.row_heights[row] += total_height; } }