我是.NET UI的新手,我来自tk UI编程的背景,所以我正在努力寻找相应的做事方法。也许.NET有一种我不知道的方法可以实现同样的结果。
因此,我试图做的事情大致如图1所示。
我们有一个页眉部分,一个正文部分和一个页脚部分。它们每个都有许多控件。我想找到的是一种方法,让页眉和页脚都有一定的高度并水平伸展;让身体部分伸展以填充其余部分。有没有一种方法可以做到这一点,而不需要计算点的位置,只需说"将页眉向上,将页脚向下,并将身体放在中间"
顶部控件-锚点:左、右、顶部
MiddleControl-锚点:左、右、上、下
底部控制-锚点:左、右、底部
namespace ChartApp
{
partial class Form2
{
/// <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.panel1 = new System.Windows.Forms.Panel();
this.panel2 = new System.Windows.Forms.Panel();
this.panel3 = new System.Windows.Forms.Panel();
this.SuspendLayout();
//
// panel1
//
this.panel1.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.panel1.BackColor = System.Drawing.Color.Maroon;
this.panel1.Location = new System.Drawing.Point(0, 87);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(599, 266);
this.panel1.TabIndex = 0;
//
// panel2
//
this.panel2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.panel2.BackColor = System.Drawing.Color.Coral;
this.panel2.Location = new System.Drawing.Point(0, 353);
this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(599, 86);
this.panel2.TabIndex = 1;
//
// panel3
//
this.panel3.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.panel3.BackColor = System.Drawing.SystemColors.ActiveCaption;
this.panel3.Location = new System.Drawing.Point(0, 0);
this.panel3.Name = "panel3";
this.panel3.Size = new System.Drawing.Size(600, 86);
this.panel3.TabIndex = 2;
//
// Form2
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(600, 439);
this.Controls.Add(this.panel3);
this.Controls.Add(this.panel2);
this.Controls.Add(this.panel1);
this.Name = "Form2";
this.Text = "Form2";
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.Panel panel2;
private System.Windows.Forms.Panel panel3;
}
}