我有一个带有tableLayoutPanel的表单。它有1列,2行有2个控件。标签和listView。在设计模式中,我不能将标签高度设置为大于17.而listView我可以手动放大但不缩小。控件尺寸仍然大于表单本身。因此,无论是控件是cliped还是我最终都使用表单滚动条。那么为什么控件自动调整大于表格呢?当我运行应用程序时,他们也不会缩小到minSize。
//
// labelTitle
//
resources.ApplyResources(this.labelTitle, "labelTitle");
this.labelTitle.ForeColor = System.Drawing.Color.DeepSkyBlue;
this.labelTitle.Name = "labelTitle";
//
// tableLayoutPanel
//
resources.ApplyResources(this.tableLayoutPanel, "tableLayoutPanel");
this.tableLayoutPanel.Controls.Add(this.labelTitle, 0, 0);
this.tableLayoutPanel.Controls.Add(this.aListView, 0, 1);
this.tableLayoutPanel.GrowStyle = System.Windows.Forms.TableLayoutPanelGrowStyle.FixedSize;
this.tableLayoutPanel.Name = "tableLayoutPanel";
//
// aListView
//
resources.ApplyResources(this.aListView, "aListView");
this.aListView.AllowDrop = true;
this.aListView.BackColor = System.Drawing.SystemColors.Desktop;
this.aListView.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.aListView.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.None;
this.aListView.LargeImageList = this.coverImageList;
this.aListView.MultiSelect = false;
this.aListView.Name = "aListView";
this.aListView.ShowGroups = false;
this.aListView.ShowItemToolTips = true;
this.aListView.TileSize = new System.Drawing.Size(200, 200);
this.aListView.UseCompatibleStateImageBehavior = false;
this.aListView.View = System.Windows.Forms.View.Tile;
//
// form
//
resources.ApplyResources(this, "$this");
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.SystemColors.Desktop;
this.Controls.Add(this.tableLayoutPanel);
this.Name = "Form";
this.albumsContextMenu.ResumeLayout(false);
this.tableLayoutPanel.ResumeLayout(false);
this.ResumeLayout(false);
而不是对接控件我锚定了它们。现在,如果我先从顶部控件开始,我可以在设计模式下更改它们的大小。
答案 0 :(得分:3)
Label
默认为AutoSize = true
,根据内容调整控件大小,忽略手动设置。
在看到更改大小的效果之前,您必须禁用AutoSize
属性。
label1.AutoSize = false;
label1.Height = 50;
(请注意,您可以先设置“高度”,但在禁用“自动调整大小”之前,您将无法看到效果。)
对于第二个问题,你必须详细说明你的意思" listView只会增加大小" 。