Changed the setting control to adjust its height as needed

This commit is contained in:
Thorsten Sommer 2022-07-27 21:38:54 +02:00
parent 506a21e792
commit fa74291e39
Signed by: tsommer
GPG Key ID: 371BBA77A02C0108
2 changed files with 13 additions and 5 deletions

View File

@ -52,7 +52,7 @@
this.tableLayout.Name = "tableLayout";
this.tableLayout.RowCount = 1;
this.tableLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayout.Size = new System.Drawing.Size(1264, 70);
this.tableLayout.Size = new System.Drawing.Size(1000, 72);
this.tableLayout.TabIndex = 0;
//
// labelExplanation
@ -61,7 +61,7 @@
this.labelExplanation.Dock = System.Windows.Forms.DockStyle.Fill;
this.labelExplanation.Location = new System.Drawing.Point(539, 0);
this.labelExplanation.Name = "labelExplanation";
this.labelExplanation.Size = new System.Drawing.Size(722, 70);
this.labelExplanation.Size = new System.Drawing.Size(458, 72);
this.labelExplanation.TabIndex = 1;
this.labelExplanation.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
@ -71,7 +71,7 @@
this.labelSettingName.Dock = System.Windows.Forms.DockStyle.Fill;
this.labelSettingName.Location = new System.Drawing.Point(69, 0);
this.labelSettingName.Name = "labelSettingName";
this.labelSettingName.Size = new System.Drawing.Size(244, 70);
this.labelSettingName.Size = new System.Drawing.Size(244, 72);
this.labelSettingName.TabIndex = 2;
this.labelSettingName.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
@ -81,7 +81,7 @@
this.labelIcon.Dock = System.Windows.Forms.DockStyle.Fill;
this.labelIcon.Location = new System.Drawing.Point(3, 0);
this.labelIcon.Name = "labelIcon";
this.labelIcon.Size = new System.Drawing.Size(60, 70);
this.labelIcon.Size = new System.Drawing.Size(60, 72);
this.labelIcon.TabIndex = 3;
//
// Setting
@ -92,7 +92,7 @@
this.Controls.Add(this.tableLayout);
this.Font = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.Name = "Setting";
this.Size = new System.Drawing.Size(1264, 70);
this.Size = new System.Drawing.Size(1000, 72);
this.tableLayout.ResumeLayout(false);
this.tableLayout.PerformLayout();
this.ResumeLayout(false);

View File

@ -18,6 +18,14 @@ public partial class Setting : UserControl
this.labelSettingName.Text = settingMetaData.SettingName();
this.labelExplanation.Text = settingMetaData.SettingExplanation();
// Calculate the needed height of the explanation label when the parent window is resized:
this.tableLayout.Resize += (sender, args) =>
{
// Adjust the height of the parent controls (table & user control):
this.tableLayout.Height = Math.Max((int)this.labelExplanation.CreateGraphics().MeasureString(this.labelExplanation.Text, this.labelExplanation.Font, new SizeF(this.labelExplanation.Width, 1000)).Height, 66);
this.Height = this.tableLayout.Height + this.tableLayout.Margin.Vertical;
};
var dataControl = settingMetaData.SetupDataControl();
this.tableLayout.Controls.Add(dataControl, 2, 0);
}