启用调整大小的 Windows Forms 窗体。

3
我该如何通过点击边框来调整表单大小?我已将FormBorderStyle设置为sizable,但是还需要做什么呢?
以下是表单的属性: Properties1 Enter image description here Designer.cs 中的表单部分:
        //
        // Form1
        //
        this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
        this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
        this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
        this.ClientSize = new System.Drawing.Size(750, 378);
        this.Controls.Add(this.rtxt_inactiveprograms);
        this.Controls.Add(this.lbl_time);
        this.Controls.Add(this.lsv_runningapps);
        this.Controls.Add(this.btn_start);
        this.Controls.Add(this.label3);
        this.Controls.Add(this.textBox2);
        this.Controls.Add(this.lst_runningprocess);
        this.Controls.Add(this.label2);
        this.Controls.Add(this.label1);
        this.Controls.Add(this.txt_pcname);
        this.Controls.Add(this.btn_ping);
        this.Name = "Form1";
        this.Text = "Form1";
        this.Load += new System.EventHandler(this.Form1_Load);
        this.ResumeLayout(false);
        this.PerformLayout();

检查一下你给form1.MaximizeBox和form1.MinimizeBox赋了什么值,这些值应该被设置为false。 - Dnyanesh
@Dnyanesh 您的意思是 0,0 表示假吗? - NatsuDragneel
@GrantWinney 我在Form1_load事件中写了this.Location = new Point(0, 0);this.Size = Screen.PrimaryScreen.WorkingArea.Size;,我应该将它们删除吗? - NatsuDragneel
@GrantWinney 嗯,我现在还好。谢谢。 - NatsuDragneel
我的错,抱歉。本意是将form1.MaximizeBox和form1.MinimizeBox设置为true。因为这会停止最小化和最大化按钮的工作。只是为了提供详细信息http://msdn.microsoft.com/en-us/library/system.windows.forms.form.maximizebox(v=vs.110).aspx。 - Dnyanesh
显示剩余5条评论
2个回答

4
这里的调整大小问题就在于你只需要将 AutoSizeModeGrowAndShrink 改为 GrowOnly

但是这里的调整大小并不影响表单内容,也无法根据分辨率进行调整。


0
FormBorderStyle 设置为 Sizable

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接