[英]Table layout panel not resizing
我有以下代码,我有一个Form
,上面带有Tabcontrol
。 在TabControl
,我有一个TabPage
,在上面有一个带有3 TextBox
和3 CheckBox
的TableLayoutPanel
。 我已经尝试了所有可能的措施来调整TableLayoutPanel
大小,但是它没有调整大小。 如果有人指出我在代码中所犯的错误是很好的。 我在下面发布代码:
CheckBox TitleCheckBox = new CheckBox() ;
TitleCheckBox.Checked = false ;
TextBox TextBoxTitle = new TextBox() ;
TextBoxTitle.Size = new Size(200,50) ;
TextBoxTitle.Text = "Enter the title of file or folder here.";
CheckBox ExtensionCheckBox = new CheckBox();
ExtensionCheckBox.Checked = false;
TextBox TextBoxExtension = new TextBox();
TextBoxExtension.Size = new Size(200, 50);
TextBoxExtension.Text = "Enter the extension for file here.";
CheckBox SizeCheckBox = new CheckBox();
SizeCheckBox.Checked = false;
TextBox TextBoxSize = new TextBox();
TextBoxSize.Text = "Enter the size for file or folder here.";
TextBoxSize.Size = new Size(200, 50);
TableLayoutPanel LayoutPanelGeneral = new TableLayoutPanel() ;
LayoutPanelGeneral.RowCount = 3 ;
LayoutPanelGeneral.ColumnCount = 2;
LayoutPanelGeneral.RowStyles.Add(new RowStyle(SizeType.AutoSize)) ;
LayoutPanelGeneral.RowStyles.Add(new RowStyle(SizeType.AutoSize)) ;
LayoutPanelGeneral.RowStyles.Add(new RowStyle(SizeType.AutoSize)) ;
LayoutPanelGeneral.ColumnStyles.Add(new ColumnStyle(SizeType.AutoSize)) ;
LayoutPanelGeneral.ColumnStyles.Add(new ColumnStyle(SizeType.AutoSize)) ;
LayoutPanelGeneral.Controls.Add(TextBoxTitle, 0,0) ;
LayoutPanelGeneral.Controls.Add(TitleCheckBox, 1,0) ;
LayoutPanelGeneral.Controls.Add(TextBoxExtension, 0, 1);
LayoutPanelGeneral.Controls.Add(ExtensionCheckBox, 1, 1);
LayoutPanelGeneral.Controls.Add(TextBoxSize, 0, 2);
LayoutPanelGeneral.Controls.Add(SizeCheckBox, 1, 2);
TabControl AdvancedTabControl = new TabControl();
TabPage TabPageGeneral = new TabPage();
TabPageGeneral.Size = new System.Drawing.Size(1300, 800);
TabPageGeneral.Name = "TabPageGeneral";
TabPageGeneral.Text = "General";
Form AdvancedForm = new Form();
AdvancedForm.Text = "Advanced Mode";
AdvancedForm.MinimizeBox = false;
AdvancedForm.MaximizeBox = false;
TabPageGeneral.Size = AdvancedForm.Size;
LayoutPanelGeneral.Size = TabPageGeneral.Size;
AdvancedForm.Controls.Add(AdvancedTabControl);
AdvancedTabControl.TabPages.Add(TabPageGeneral);
TabPageGeneral.Controls.Add(LayoutPanelGeneral) ;
AdvancedForm.ShowDialog() ;
总的来说,我尝试了以下措施:
1)更改TableLayoutPanel
的width
和height
2)将AutoSize
设置为true
;
遇到了相同的问题,并通过以下方法解决了问题:
((ISupportInitialize)(this.tabControl1)).BeginInit();
[...]
((ISupportInitialize)(this.tabControl1)).EndInit();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.