类似于我在这里提出的问题,当我使用我制作的表单作为基类并重新调整它的大小时,我的按钮丢失了。我确定这是因为我重新调整了表单的大小并且按钮放置在页面之外的位置,所以当我重新调整大小时它们仍然在页面之外,只是不知道如何修复它。一个简单的解决方法是在加载事件时重新调整大小,但这并不能让我正确设计页面 - 另外我真的只是希望按钮总是从底部向上 10-20 和从右侧 5-15 - 无论我如何重新调整表格的大小。提前致谢。
基本形式:
namespace EXT
{
partial class ExtFormCard
{
private void InitializeComponent ()
{
this.btnSaveandClose = new System.Windows.Forms.Button();
this.btnCancel = new System.Windows.Forms.Button();
this.btnSave = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// btnSaveandClose
//
this.btnSaveandClose.Anchor = ((System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.btnSaveandClose.Location = new System.Drawing.Point(899, 663);
this.btnSaveandClose.Name = "btnSaveandClose";
this.btnSaveandClose.Size = new System.Drawing.Size(100, 30);
this.btnSaveandClose.TabIndex = 0;
this.btnSaveandClose.Text = "Save and Close";
this.btnSaveandClose.UseVisualStyleBackColor = true;
this.btnSaveandClose.Click += new System.EventHandler(this.Click_SaveandClose);
... other buttons
...
//
// ExtFormCard
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1200, 874);
this.Controls.Add(this.btnSave);
this.Controls.Add(this.btnCancel);
this.Controls.Add(this.btnSaveandClose);
this.Name = "ExtFormCard";
this.Text = "ExtFormCard";
this.ResumeLayout(false);
}
private System.Windows.Forms.Button btnSaveandClose;
private System.Windows.Forms.Button btnCancel;
private System.Windows.Forms.Button btnSave;
}
}
新形式:
namespace IDVisitorWindowsForms.Manager
{
public partial class AnswerForm : EXT.ExtFormCard
{
public AnswerForm ()
{
InitializeComponent ();
}
}
}
namespace IDVisitorWindowsForms.Manager
{
partial class AnswerForm
{
#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.SuspendLayout();
//
// AnswerForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF (6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size (724, 411);
this.Name = "AnswerForm";
this.Text = "Answer Form";
this.Load += new System.EventHandler(this.AnswerForm_Load);
this.ResumeLayout(false);
}
#endregion
}
}