0

我发现了一个类似的问题,但答案只有助于使其中一个滚动条出现。

我的表单有一个 SplitContainer。在它的一个面板(Panel2)中,有一个带有我想要显示的图像的 PictureBox。

我需要的是找到一种方法,当图像超过面板的大小时,使垂直和水平滚动条都出现。

我已经将 AutoScroll 设置为 true,并且我已经看到有必要在左侧设置 Anchor 以显示其中一个滚动条,并在顶部设置另一个滚动条,但我需要它们两个。

提前致谢。

4

2 回答 2

1

确保嵌入 PictureBox 的 SplitContainer.Panel 的 AutoScroll 属性设置为 True,并且 PictureBox 的 SizeMode 属性设置为“AutoSize”(PictureBoxSizeMode.AutoSize)。

希望我帮助你:)

于 2020-11-27T19:14:58.313 回答
0

我没有发现任何问题设置这样的东西。这是我的设计器代码:

partial class Form1
{
    /// <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.pictureBox1 = new System.Windows.Forms.PictureBox();
        ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
        this.splitContainer1.Panel2.SuspendLayout();
        this.splitContainer1.SuspendLayout();
        ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
        this.SuspendLayout();
        // 
        // splitContainer1
        // 
        this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
        this.splitContainer1.Location = new System.Drawing.Point(0, 0);
        this.splitContainer1.Name = "splitContainer1";
        // 
        // splitContainer1.Panel2
        // 
        this.splitContainer1.Panel2.AutoScroll = true;
        this.splitContainer1.Panel2.Controls.Add(this.pictureBox1);
        this.splitContainer1.Size = new System.Drawing.Size(576, 406);
        this.splitContainer1.SplitterDistance = 192;
        this.splitContainer1.TabIndex = 0;
        // 
        // pictureBox1
        // 
        this.pictureBox1.Image = global::WinFormsScratch.Properties.Resources.Desert;
        this.pictureBox1.Location = new System.Drawing.Point(0, 0);
        this.pictureBox1.Name = "pictureBox1";
        this.pictureBox1.Size = new System.Drawing.Size(1024, 768);
        this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
        this.pictureBox1.TabIndex = 0;
        this.pictureBox1.TabStop = false;
        // 
        // Form1
        // 
        this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
        this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
        this.ClientSize = new System.Drawing.Size(576, 406);
        this.Controls.Add(this.splitContainer1);
        this.Name = "Form1";
        this.Text = "Form1";
        this.splitContainer1.Panel2.ResumeLayout(false);
        this.splitContainer1.Panel2.PerformLayout();
        ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit();
        this.splitContainer1.ResumeLayout(false);
        ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
        this.ResumeLayout(false);

    }

    #endregion

    private System.Windows.Forms.SplitContainer splitContainer1;
    private System.Windows.Forms.PictureBox pictureBox1;





}
于 2013-06-18T16:24:11.130 回答