最小化表单时如何在面板中自动显示水平滚动条?

时间:2019-05-10 01:01:58

标签: c# winforms scroll panel

我有一个组合框来显示我的配置项。组框位于窗体的面板中。

加载表单时,它将以最大化模式打开。在此期间,显示的面板垂直滚动条是正确的。此时未显示水平滚动条,因为我仍然可以看到所有正确的文本。

但是当我最小化问题所在的表格时。我看不到配置项的全部文本,并且由于没有水平滚动条,因此无法向右滚动以阅读配置文件。有办法解决吗?还是有办法始终始终启用水平滚动条?请帮忙。谢谢。

        // 
        // panel1
        // 
        this.panel1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
        | System.Windows.Forms.AnchorStyles.Right)));
        this.panel1.AutoScroll = true;
        this.panel1.Controls.Add(this.grpBoxConfItems);
        this.panel1.Font = new System.Drawing.Font("Microsoft Sans Serif", 11.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
        this.panel1.Location = new System.Drawing.Point(1164, 224);
        this.panel1.Margin = new System.Windows.Forms.Padding(6, 6, 6, 6);
        this.panel1.Name = "panel1";
        this.panel1.Size = new System.Drawing.Size(682, 810);
        this.panel1.TabIndex = 4;
        // 
        // grpBoxConfItems
        // 
        this.grpBoxConfItems.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
        | System.Windows.Forms.AnchorStyles.Right)));
        this.grpBoxConfItems.AutoSize = true;
        this.grpBoxConfItems.Controls.Add(this.lblValue);
        this.grpBoxConfItems.Controls.Add(this.lblKey);
        this.grpBoxConfItems.Font = new System.Drawing.Font("Microsoft Sans Serif", 11.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
        this.grpBoxConfItems.Location = new System.Drawing.Point(34, 32);
        this.grpBoxConfItems.Margin = new System.Windows.Forms.Padding(6, 6, 6, 6);
        this.grpBoxConfItems.Name = "grpBoxConfItems";
        this.grpBoxConfItems.Padding = new System.Windows.Forms.Padding(6, 6, 6, 6);
        this.grpBoxConfItems.Size = new System.Drawing.Size(712, 744);
        this.grpBoxConfItems.TabIndex = 0;
        this.grpBoxConfItems.TabStop = false;
        this.grpBoxConfItems.Text = "Configuration Items";

更新 因此,我决定使滚动条无论在最大化还是最小化模式下始终可见。

                this.panel1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
                | System.Windows.Forms.AnchorStyles.Right)));
                this.panel1.AutoScroll = false;
                this.panel1.VerticalScroll.Visible = true;
                this.panel1.VerticalScroll.Enabled = true;
                this.panel1.HorizontalScroll.Visible = true;
                this.panel1.HorizontalScroll.Enabled = true;
                this.panel1.Controls.Add(this.grpBoxConfItems);
                this.panel1.Font = new System.Drawing.Font("Microsoft Sans Serif", 11.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
                this.panel1.Location = new System.Drawing.Point(1164, 224);
                this.panel1.Margin = new System.Windows.Forms.Padding(6, 6, 6, 6);
                this.panel1.Name = "panel1";
                this.panel1.Size = new System.Drawing.Size(682, 810);
                this.panel1.TabIndex = 4;

两个滚动条均显示,但它们不起作用。当我在this.panel1.AutoScroll = true;之后设置this.panel1.HorizontalScroll.Enabled = true;时,垂直滚动条起作用,但水平滚动条丢失。请帮我如何解决这个问题?谢谢。

0 个答案:

没有答案