System\Windows\Forms\Design\TableLayoutPanelDesigner.cs (170)
53private TableLayoutPanelBehavior Behavior => _tlpBehavior ??= new TableLayoutPanelBehavior(Table, this, Component.Site);
55private TableLayoutColumnStyleCollection ColumnStyles => Table.ColumnStyles;
57private TableLayoutRowStyleCollection RowStyles => Table.RowStyles;
61get => Table.RowCount;
70Table.RowCount = value;
77get => Table.ColumnCount;
86Table.ColumnCount = value;
268if (Table is not null)
272bool colState = Table.ColumnCount > 1;
281bool rowState = Table.RowCount > 1;
411if (_owner.Table.ColumnCount > 1)
419if (_owner.Table.RowCount > 1)
448Table.ControlRemoved -= OnControlRemoved;
449Table.Controls.Remove(c);
450Table.ControlRemoved += OnControlRemoved;
455Table.ControlAdded -= OnControlAdded;
456Table.Controls.Add(c, col, row);
457Table.ControlAdded += OnControlAdded;
466if (Table.GrowStyle == TableLayoutPanelGrowStyle.AddRows)
468PropertyDescriptor rowProp = TypeDescriptor.GetProperties(Table)["RowCount"];
469rowProp?.SetValue(Table, Table.GetRowHeights().Length);
472newControlPosition.Y = Table.RowCount - 1;
474else if (Table.GrowStyle == TableLayoutPanelGrowStyle.AddColumns)
476PropertyDescriptor colProp = TypeDescriptor.GetProperties(Table)["ColumnCount"];
477colProp?.SetValue(Table, Table.GetColumnWidths().Length);
479newControlPosition.X = Table.ColumnCount - 1;
489PropertyDescriptor controlsProp = TypeDescriptor.GetProperties(Table)["Controls"];
598Table.SetCellPosition(control, new TableLayoutPanelCellPosition(newControlPosition.X, newControlPosition.Y));
639PropertyDescriptor colProp = TypeDescriptor.GetProperties(Table)["ColumnCount"];
640colProp?.SetValue(Table, DesignerUtils.s_defaultColumnCount);
642PropertyDescriptor rowProp = TypeDescriptor.GetProperties(Table)["RowCount"];
643rowProp?.SetValue(Table, DesignerUtils.s_defaultRowCount);
654Table.ColumnStyles[0].SizeType = SizeType.Percent;
655Table.ColumnStyles[0].Width = DesignerUtils.s_minimumStylePercent;
656Table.ColumnStyles[1].SizeType = SizeType.Percent;
657Table.ColumnStyles[1].Width = DesignerUtils.s_minimumStylePercent;
660Table.RowStyles[0].SizeType = SizeType.Percent;
661Table.RowStyles[0].Height = DesignerUtils.s_minimumStylePercent;
662Table.RowStyles[1].SizeType = SizeType.Percent;
663Table.RowStyles[1].Height = DesignerUtils.s_minimumStylePercent;
719if (Table.GrowStyle != TableLayoutPanelGrowStyle.FixedSize)
731int rowSpan = Table.GetRowSpan(newControl);
732int columnSpan = Table.GetColumnSpan(newControl);
735int numRows = Table.GetRowHeights().Length;
736int numColumns = Table.GetColumnWidths().Length;
755if (Table.GetControlFromPosition(column, row) is not null)
818if (Table is not null)
820Table.ControlAdded -= OnControlAdded;
821Table.ControlRemoved -= OnControlRemoved;
837if (Table.CellBorderStyle != TableLayoutPanelCellBorderStyle.None)
849int[] cw = Table.GetColumnWidths();
850int[] rh = Table.GetRowHeights();
856bool isRTL = (Table.RightToLeft == RightToLeft.Yes);
908int[] cw = Table.GetColumnWidths();
909int[] rh = Table.GetRowHeights();
911Table.SuspendLayout();
915if (cw.Length > Table.ColumnStyles.Count)
917int colDifference = cw.Length - Table.ColumnStyles.Count;
921Table.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, DesignerUtils.s_minimumStyleSize));
928if (rh.Length > Table.RowStyles.Count)
930int rowDifference = rh.Length - Table.RowStyles.Count;
934Table.RowStyles.Add(new RowStyle(SizeType.Absolute, DesignerUtils.s_minimumStyleSize));
942Table.ResumeLayout();
962int[] rows = Table.GetRowHeights();
963int[] columns = Table.GetColumnWidths();
966Point startingPoint = Table.PointToScreen(Table.DisplayRectangle.Location);
967Rectangle bounds = new(startingPoint, Table.DisplayRectangle.Size);
971bool isRTL = Table.RightToLeft == RightToLeft.Yes;
1047TableLayoutPanelCellPosition pos = Table.GetPositionFromControl(control);
1072Point loc = BehaviorService.MapAdornerWindowPoint(Table.Handle, Table.DisplayRectangle.Location);
1073Rectangle bounds = new(loc, Table.DisplayRectangle.Size);
1078int[] cw = Table.GetColumnWidths();
1079int[] rh = Table.GetRowHeights();
1082bool isRTL = (Table.RightToLeft == RightToLeft.Yes);
1113Debug.Assert(Table.ColumnStyles[i] is not null, "Table's ColumnStyle[" + i + "] is null!");
1114if (Table.ColumnStyles[i] is not null)
1116TableLayoutPanelResizeGlyph g = new(gBounds, Table.ColumnStyles[i], Cursors.VSplit, Behavior);
1139Debug.Assert(Table.RowStyles[i] is not null, $"Table's RowStyle[{i}] is null!");
1140if (Table.RowStyles[i] is not null)
1142TableLayoutPanelResizeGlyph g = new(gBounds, Table.RowStyles[i], Cursors.HSplit, Behavior);
1172_rowStyleProp = TypeDescriptor.GetProperties(Table)["RowStyles"];
1173_colStyleProp = TypeDescriptor.GetProperties(Table)["ColumnStyles"];
1199_rowCountBeforeAdd = Math.Max(0, Table.GetRowHeights().Length); // don't want negative
1200_colCountBeforeAdd = Math.Max(0, Table.GetColumnWidths().Length);
1217int[] rows = Table.GetRowHeights();
1218int[] columns = Table.GetColumnWidths();
1224if (Table.GetControlFromPosition(column, row) is not null)
1255Table.SetCellPosition(e.Control, new TableLayoutPanelCellPosition(-1, -1));
1264int[] rows = Table.GetRowHeights();
1265int[] columns = Table.GetColumnWidths();
1312if (dragControl is not null && Table.Controls.Contains(dragControl))
1339_rowCountBeforeAdd = Math.Max(0, Table.GetRowHeights().Length); // don't want negative
1340_colCountBeforeAdd = Math.Max(0, Table.GetColumnWidths().Length);
1470if (selSvc is not null && Table is not null)
1477if (c is not null && c.Parent == Table)
1484if (selSvc.GetComponentSelected(Table) || selectedComponentHasTableParent)
1487Table.SuspendLayout();
1489Table.ResumeLayout(false);
1490Table.PerformLayout();
1605switch (isRow ? Table.RowStyles[_curRow].SizeType : Table.ColumnStyles[_curCol].SizeType)
1621if ((isRow ? Table.RowCount : Table.ColumnCount) < 2)
1634if (host is not null && Table.Site is not null)
1639: SR.TableLayoutPanelDesignerAddColumnUndoUnit, Table.Site.Name));
1643Table.SuspendLayout(); // To avoid flickering
1647InsertRowCol(isRow, isRow ? Table.RowCount : Table.ColumnCount);
1648Table.ResumeLayout();
1675PropertyDescriptor rowProp = TypeDescriptor.GetProperties(Table)["RowCount"];
1679Table.RowStyles.Insert(index, new RowStyle(SizeType.Absolute, DesignerUtils.s_minimumStyleSize));
1682rowProp.SetValue(Table, Table.RowCount + 1);
1687PropertyDescriptor colProp = TypeDescriptor.GetProperties(Table)["ColumnCount"];
1691Table.ColumnStyles.Insert(index, new ColumnStyle(SizeType.Absolute, DesignerUtils.s_minimumStyleSize));
1694colProp.SetValue(Table, Table.ColumnCount + 1);
1710PropertyDescriptor childProp = TypeDescriptor.GetProperties(Table)["Controls"];
1713foreach (Control child in Table.Controls)
1715int currentIndex = isRow ? Table.GetRow(child) : Table.GetColumn(child);
1735int span = isRow ? Table.GetRowSpan(child) : Table.GetColumnSpan(child); // span is always at least 1
1749if (host is not null && Table.Site is not null)
1754Table.Site.Name));
1758Table.SuspendLayout();
1761Table.ResumeLayout();
1785PropertyDescriptor childProp = TypeDescriptor.GetProperties(Table)["Controls"];
1788foreach (Control child in Table.Controls)
1790int currentIndex = isRow ? Table.GetRow(child) : Table.GetColumn(child);
1824int span = isRow ? Table.GetRowSpan(child) : Table.GetColumnSpan(child); // span is always at least 1
1840PropertyDescriptor rowProp = TypeDescriptor.GetProperties(Table)["RowCount"];
1843rowProp.SetValue(Table, Table.RowCount - 1);
1846Table.RowStyles.RemoveAt(index);
1852PropertyDescriptor colProp = TypeDescriptor.GetProperties(Table)["ColumnCount"];
1855colProp.SetValue(Table, Table.ColumnCount - 1);
1858Table.ColumnStyles.RemoveAt(index);
1866if ((isRow ? Table.RowCount : Table.ColumnCount) < 2)
1873if (host is not null && Table.Site is not null)
1877Table.Site.Name));
1881Table.SuspendLayout();
1894PropertyDescriptor childProp = TypeDescriptor.GetProperties(Table)["Controls"];
1911Table.ResumeLayout();
1928private void OnRemove(bool isRow) => OnRemoveInternal(isRow, isRow ? Table.RowCount - 1 : Table.ColumnCount - 1);
1949styles = isRow ? Table.RowStyles : Table.ColumnStyles;
1959int[] rh = Table.GetRowHeights();
1960int[] ch = Table.GetColumnWidths();
1970if (host is not null && Table.Site is not null)
1972using DesignerTransaction t = host.CreateTransaction(string.Format(SR.TableLayoutPanelDesignerChangeSizeTypeUndoUnit, Table.Site.Name));
1976Table.SuspendLayout();
1986Table.RowStyles[index].Height = rh[index];
1990Table.ColumnStyles[index].Width = ch[index];
1998Table.RowStyles[index].Height = DesignerUtils.s_minimumStylePercent;
2002Table.ColumnStyles[index].Width = DesignerUtils.s_minimumStylePercent;
2016Table.ResumeLayout();
2049EditorServiceContext.EditValue(this, Table, "ColumnStyles");
2123Table?.Invalidate(true);
2130_compSvc.OnComponentChanging(Table, prop);
2138_compSvc.OnComponentChanged(Table, prop, null, null);