3

总而言之,我已经编写了大量的 WinForms,这个错误很奇怪,因为我以前没有遇到过。此表单是该项目中 30 多个表单之一,并且是唯一一个缩放在不同屏幕分辨率和字体缩放下表现异常的表单。

我知道该AutoScaleMode属性,并且大多数时候我将其设置为Font精确地防止我在这里遇到的错误。当我在 1920x1080 显示器上启动此表单时,一切正常

没问题

但是在 1920x1200 显示器上启动表单,组框似乎会调整大小

错误

这会迫使屏幕上的按钮并导致普遍的丑陋。如果我将默认操作系统字体从 125% 更改为 100%,我也可以在 1980x1080 显示器上发生这种情况。

顶部分组框被锚定(左、右、顶部),底部分组框被锚定(左、右、顶部、底部)。表格设置为和AutoScaleModeFont其他控件不是 AutoSized

有什么问题,我该如何解决?

谢谢你的时间。

编辑:设计器文件如下。

namespace IPACost
{
    partial class CreateNationalDbForm
    {
        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Windows Form Designer generated code

        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.splitContainer1 = new System.Windows.Forms.SplitContainer();
            this.customTreeViewSql = new IPACost.CustomTreeView();
            this.panelBottom = new System.Windows.Forms.Panel();
            this.buttonRefresh = new System.Windows.Forms.Button();
            this.groupBoxBottom = new System.Windows.Forms.GroupBox();
            this.pictureBox1 = new System.Windows.Forms.PictureBox();
            this.customRichTextBox1 = new IPACost.CustomRichTextBox();
            this.labelInfo = new System.Windows.Forms.Label();
            this.groupBoxTop = new System.Windows.Forms.GroupBox();
            this.checkBoxInclSNAP = new System.Windows.Forms.CheckBox();
            this.label2 = new System.Windows.Forms.Label();
            this.comboBoxUnits = new System.Windows.Forms.ComboBox();
            this.label1 = new System.Windows.Forms.Label();
            this.textBoxIniSize = new System.Windows.Forms.TextBox();
            this.labelName = new System.Windows.Forms.Label();
            this.textBoxDbName = new System.Windows.Forms.TextBox();
            this.buttonNoFilter = new System.Windows.Forms.Button();
            this.buttonCancel = new System.Windows.Forms.Button();
            this.buttonAppend = new System.Windows.Forms.Button();
            ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
            this.splitContainer1.Panel1.SuspendLayout();
            this.splitContainer1.Panel2.SuspendLayout();
            this.splitContainer1.SuspendLayout();
            this.panelBottom.SuspendLayout();
            this.groupBoxBottom.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
            this.groupBoxTop.SuspendLayout();
            this.SuspendLayout();
            // 
            // splitContainer1
            // 
            this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
            this.splitContainer1.Location = new System.Drawing.Point(0, 0);
            this.splitContainer1.Margin = new System.Windows.Forms.Padding(2);
            this.splitContainer1.Name = "splitContainer1";
            // 
            // splitContainer1.Panel1
            // 
            this.splitContainer1.Panel1.Controls.Add(this.customTreeViewSql);
            this.splitContainer1.Panel1.Controls.Add(this.panelBottom);
            // 
            // splitContainer1.Panel2
            // 
            this.splitContainer1.Panel2.Controls.Add(this.groupBoxBottom);
            this.splitContainer1.Panel2.Controls.Add(this.groupBoxTop);
            this.splitContainer1.Panel2.Controls.Add(this.buttonNoFilter);
            this.splitContainer1.Panel2.Controls.Add(this.buttonCancel);
            this.splitContainer1.Panel2.Controls.Add(this.buttonAppend);
            this.splitContainer1.Size = new System.Drawing.Size(705, 357);
            this.splitContainer1.SplitterDistance = 199;
            this.splitContainer1.SplitterWidth = 6;
            this.splitContainer1.TabIndex = 0;
            // 
            // customTreeViewSql
            // 
            this.customTreeViewSql.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
            this.customTreeViewSql.Dock = System.Windows.Forms.DockStyle.Fill;
            this.customTreeViewSql.DrawMode = System.Windows.Forms.TreeViewDrawMode.OwnerDrawText;
            this.customTreeViewSql.Font = new System.Drawing.Font("Arial", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.customTreeViewSql.HotTrackFont = new System.Drawing.Font("Arial", 9F, System.Drawing.FontStyle.Underline, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.customTreeViewSql.HotTracking = true;
            this.customTreeViewSql.LineColor = System.Drawing.Color.FromArgb(((int)(((byte)(109)))), ((int)(((byte)(109)))), ((int)(((byte)(109)))));
            this.customTreeViewSql.Location = new System.Drawing.Point(0, 0);
            this.customTreeViewSql.Margin = new System.Windows.Forms.Padding(2);
            this.customTreeViewSql.Name = "customTreeViewSql";
            this.customTreeViewSql.ShowNodeToolTips = true;
            this.customTreeViewSql.Size = new System.Drawing.Size(199, 320);
            this.customTreeViewSql.TabIndex = 7;
            this.customTreeViewSql.NodeMouseClick += new System.Windows.Forms.TreeNodeMouseClickEventHandler(this.customTreeViewSql_NodeMouseClick);
            // 
            // panelBottom
            // 
            this.panelBottom.Controls.Add(this.buttonRefresh);
            this.panelBottom.Dock = System.Windows.Forms.DockStyle.Bottom;
            this.panelBottom.Location = new System.Drawing.Point(0, 320);
            this.panelBottom.Margin = new System.Windows.Forms.Padding(2);
            this.panelBottom.Name = "panelBottom";
            this.panelBottom.Size = new System.Drawing.Size(199, 37);
            this.panelBottom.TabIndex = 7;
            // 
            // buttonRefresh
            // 
            this.buttonRefresh.Anchor = System.Windows.Forms.AnchorStyles.Bottom;
            this.buttonRefresh.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
            this.buttonRefresh.Location = new System.Drawing.Point(2, 2);
            this.buttonRefresh.Margin = new System.Windows.Forms.Padding(2);
            this.buttonRefresh.Name = "buttonRefresh";
            this.buttonRefresh.Size = new System.Drawing.Size(195, 33);
            this.buttonRefresh.TabIndex = 8;
            this.buttonRefresh.Text = "Show Database Structure";
            this.buttonRefresh.UseVisualStyleBackColor = true;
            this.buttonRefresh.Click += new System.EventHandler(this.buttonRefresh_Click);
            // 
            // groupBoxBottom
            // 
            this.groupBoxBottom.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
            | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this.groupBoxBottom.Controls.Add(this.pictureBox1);
            this.groupBoxBottom.Controls.Add(this.customRichTextBox1);
            this.groupBoxBottom.Controls.Add(this.labelInfo);
            this.groupBoxBottom.Location = new System.Drawing.Point(4, 120);
            this.groupBoxBottom.Name = "groupBoxBottom";
            this.groupBoxBottom.Size = new System.Drawing.Size(480, 188);
            this.groupBoxBottom.TabIndex = 12;
            this.groupBoxBottom.TabStop = false;
            this.groupBoxBottom.Text = "Additional SQL Filtering [WHERE:]";
            // 
            // pictureBox1
            // 
            this.pictureBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
            this.pictureBox1.Image = global::IPACost.Properties.Resources.Info;
            this.pictureBox1.Location = new System.Drawing.Point(5, 122);
            this.pictureBox1.Margin = new System.Windows.Forms.Padding(2);
            this.pictureBox1.Name = "pictureBox1";
            this.pictureBox1.Size = new System.Drawing.Size(38, 38);
            this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
            this.pictureBox1.TabIndex = 2;
            this.pictureBox1.TabStop = false;
            // 
            // customRichTextBox1
            // 
            this.customRichTextBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
            | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this.customRichTextBox1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
            this.customRichTextBox1.Font = new System.Drawing.Font("Consolas", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.customRichTextBox1.Location = new System.Drawing.Point(5, 20);
            this.customRichTextBox1.Margin = new System.Windows.Forms.Padding(2);
            this.customRichTextBox1.Name = "customRichTextBox1";
            this.customRichTextBox1.Size = new System.Drawing.Size(472, 86);
            this.customRichTextBox1.TabIndex = 3;
            this.customRichTextBox1.Text = "e.g. [B1A].[ProdType] IN (\'AC\', \'NB\', \'AE\')";
            // 
            // labelInfo
            // 
            this.labelInfo.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this.labelInfo.Location = new System.Drawing.Point(47, 108);
            this.labelInfo.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
            this.labelInfo.Name = "labelInfo";
            this.labelInfo.Size = new System.Drawing.Size(428, 77);
            this.labelInfo.TabIndex = 1;
            this.labelInfo.Text = "This filters the create database result sets for the National Databases. The filt" +
    "ering SQL should only contain a valid WHERE clause on the core data table [B1A]." +
    " The \'WHERE\' Keyword is not required.\r\n";
            // 
            // groupBoxTop
            // 
            this.groupBoxTop.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this.groupBoxTop.Controls.Add(this.checkBoxInclSNAP);
            this.groupBoxTop.Controls.Add(this.label2);
            this.groupBoxTop.Controls.Add(this.comboBoxUnits);
            this.groupBoxTop.Controls.Add(this.label1);
            this.groupBoxTop.Controls.Add(this.textBoxIniSize);
            this.groupBoxTop.Controls.Add(this.labelName);
            this.groupBoxTop.Controls.Add(this.textBoxDbName);
            this.groupBoxTop.Location = new System.Drawing.Point(2, 10);
            this.groupBoxTop.Margin = new System.Windows.Forms.Padding(2);
            this.groupBoxTop.Name = "groupBoxTop";
            this.groupBoxTop.Padding = new System.Windows.Forms.Padding(2);
            this.groupBoxTop.Size = new System.Drawing.Size(479, 105);
            this.groupBoxTop.TabIndex = 11;
            this.groupBoxTop.TabStop = false;
            this.groupBoxTop.Text = "National Database Details:";
            // 
            // checkBoxInclSNAP
            // 
            this.checkBoxInclSNAP.AutoSize = true;
            this.checkBoxInclSNAP.Location = new System.Drawing.Point(155, 76);
            this.checkBoxInclSNAP.Margin = new System.Windows.Forms.Padding(2);
            this.checkBoxInclSNAP.Name = "checkBoxInclSNAP";
            this.checkBoxInclSNAP.Size = new System.Drawing.Size(148, 21);
            this.checkBoxInclSNAP.TabIndex = 14;
            this.checkBoxInclSNAP.Text = "Include SNAP data";
            this.checkBoxInclSNAP.UseVisualStyleBackColor = true;
            // 
            // label2
            // 
            this.label2.AutoSize = true;
            this.label2.Location = new System.Drawing.Point(290, 51);
            this.label2.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
            this.label2.Name = "label2";
            this.label2.Size = new System.Drawing.Size(160, 17);
            this.label2.TabIndex = 13;
            this.label2.Text = "Default growth rate 20%";
            // 
            // comboBoxUnits
            // 
            this.comboBoxUnits.FormattingEnabled = true;
            this.comboBoxUnits.Items.AddRange(new object[] {
            "B",
            "KB",
            "MB",
            "GB",
            "TB",
            "PB"});
            this.comboBoxUnits.Location = new System.Drawing.Point(232, 48);
            this.comboBoxUnits.Margin = new System.Windows.Forms.Padding(2);
            this.comboBoxUnits.Name = "comboBoxUnits";
            this.comboBoxUnits.Size = new System.Drawing.Size(53, 24);
            this.comboBoxUnits.TabIndex = 12;
            this.comboBoxUnits.Text = "MB";
            // 
            // label1
            // 
            this.label1.AutoSize = true;
            this.label1.Location = new System.Drawing.Point(12, 51);
            this.label1.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(139, 17);
            this.label1.TabIndex = 11;
            this.label1.Text = "Estimated initial size:";
            // 
            // textBoxIniSize
            // 
            this.textBoxIniSize.Location = new System.Drawing.Point(155, 48);
            this.textBoxIniSize.Margin = new System.Windows.Forms.Padding(2);
            this.textBoxIniSize.Name = "textBoxIniSize";
            this.textBoxIniSize.Size = new System.Drawing.Size(74, 22);
            this.textBoxIniSize.TabIndex = 10;
            this.textBoxIniSize.Text = "100";
            this.textBoxIniSize.Leave += new System.EventHandler(this.textBoxIniSize_Leave);
            // 
            // labelName
            // 
            this.labelName.AutoSize = true;
            this.labelName.Location = new System.Drawing.Point(39, 24);
            this.labelName.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
            this.labelName.Name = "labelName";
            this.labelName.Size = new System.Drawing.Size(112, 17);
            this.labelName.TabIndex = 9;
            this.labelName.Text = "Database name:";
            // 
            // textBoxDbName
            // 
            this.textBoxDbName.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this.textBoxDbName.Location = new System.Drawing.Point(155, 21);
            this.textBoxDbName.Margin = new System.Windows.Forms.Padding(2);
            this.textBoxDbName.Name = "textBoxDbName";
            this.textBoxDbName.Size = new System.Drawing.Size(287, 22);
            this.textBoxDbName.TabIndex = 1;
            // 
            // buttonNoFilter
            // 
            this.buttonNoFilter.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
            this.buttonNoFilter.Location = new System.Drawing.Point(258, 313);
            this.buttonNoFilter.Margin = new System.Windows.Forms.Padding(2);
            this.buttonNoFilter.Name = "buttonNoFilter";
            this.buttonNoFilter.Size = new System.Drawing.Size(104, 33);
            this.buttonNoFilter.TabIndex = 5;
            this.buttonNoFilter.Text = "Run No Filter";
            this.buttonNoFilter.UseVisualStyleBackColor = true;
            this.buttonNoFilter.Click += new System.EventHandler(this.buttonNoFilter_Click);
            // 
            // buttonCancel
            // 
            this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
            this.buttonCancel.Location = new System.Drawing.Point(162, 313);
            this.buttonCancel.Margin = new System.Windows.Forms.Padding(2);
            this.buttonCancel.Name = "buttonCancel";
            this.buttonCancel.Size = new System.Drawing.Size(92, 33);
            this.buttonCancel.TabIndex = 4;
            this.buttonCancel.Text = "Cancel";
            this.buttonCancel.UseVisualStyleBackColor = true;
            this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click);
            // 
            // buttonAppend
            // 
            this.buttonAppend.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
            this.buttonAppend.Location = new System.Drawing.Point(366, 313);
            this.buttonAppend.Margin = new System.Windows.Forms.Padding(2);
            this.buttonAppend.Name = "buttonAppend";
            this.buttonAppend.Size = new System.Drawing.Size(117, 33);
            this.buttonAppend.TabIndex = 6;
            this.buttonAppend.Text = "Run Use Filter";
            this.buttonAppend.UseVisualStyleBackColor = true;
            this.buttonAppend.Click += new System.EventHandler(this.buttonAppend_Click);
            // 
            // CreateNationalDbForm
            // 
            this.AcceptButton = this.buttonNoFilter;
            this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(705, 357);
            this.Controls.Add(this.splitContainer1);
            this.Margin = new System.Windows.Forms.Padding(2);
            this.MaximizeBox = false;
            this.MinimizeBox = false;
            this.MinimumSize = new System.Drawing.Size(523, 303);
            this.Name = "CreateNationalDbForm";
            this.ShowIcon = false;
            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
            this.Text = "Special Processes Options";
            this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.SpecialSqlForm_FormClosing);
            this.Load += new System.EventHandler(this.SpecialSqlForm_Load);
            this.splitContainer1.Panel1.ResumeLayout(false);
            this.splitContainer1.Panel2.ResumeLayout(false);
            ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit();
            this.splitContainer1.ResumeLayout(false);
            this.panelBottom.ResumeLayout(false);
            this.groupBoxBottom.ResumeLayout(false);
            ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
            this.groupBoxTop.ResumeLayout(false);
            this.groupBoxTop.PerformLayout();
            this.ResumeLayout(false);

        }

        #endregion

        private System.Windows.Forms.SplitContainer splitContainer1;
        private CustomTreeView customTreeViewSql;
        private System.Windows.Forms.Panel panelBottom;
        private System.Windows.Forms.Button buttonRefresh;
        private System.Windows.Forms.Label labelInfo;
        private System.Windows.Forms.Button buttonCancel;
        private System.Windows.Forms.Button buttonAppend;
        private CustomRichTextBox customRichTextBox1;
        private System.Windows.Forms.Button buttonNoFilter;
        private System.Windows.Forms.Label labelName;
        private System.Windows.Forms.TextBox textBoxDbName;
        private System.Windows.Forms.GroupBox groupBoxTop;
        private System.Windows.Forms.PictureBox pictureBox1;
        private System.Windows.Forms.Label label1;
        private System.Windows.Forms.TextBox textBoxIniSize;
        private System.Windows.Forms.ComboBox comboBoxUnits;
        private System.Windows.Forms.Label label2;
        private System.Windows.Forms.CheckBox checkBoxInclSNAP;
        private System.Windows.Forms.GroupBox groupBoxBottom;
    }
}
4

1 回答 1

5

我无法确定此问题的确切原因。但是,经过大约一百万次表单和控件设置的迭代,我确实提出了一个解决方案。它是在控件内部插入另一个Panel停靠的。这似乎现在可以防止任何奇怪的缩放问题可能是从底层继承的。FillPanel2SplitContainerSplitContainer

这不是为什么会发生这种情况的答案,但它是一个修复程序,希望它可以帮助其他人。

谢谢你的时间。

于 2012-10-04T10:38:24.373 回答