C#中lable及其内容怎样随对话框的改变成比例的改变,窗体中有四个lable控件,两行两列排列对话框c#

解决方案 »

  1.   

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;namespace WindowsFormsApplication1
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }        private void Form1_Load(object sender, EventArgs e)
            {
                label1.AutoSize = false;
                label1.Dock = DockStyle.Left;
                label1.TextAlign = ContentAlignment.MiddleLeft;
                label2.AutoSize = false;
                label2.Dock = DockStyle.Right;
                label2.TextAlign = ContentAlignment.MiddleRight;
                label3.AutoSize = false;
                label3.Dock = DockStyle.Top;
                label3.TextAlign = ContentAlignment.TopCenter;
                label4.AutoSize = false;
                label4.Dock = DockStyle.Bottom;
                label4.TextAlign = ContentAlignment.BottomCenter;
                Label[] labels = { label1, label2, label3, label4 };
                foreach (Label l in labels)
                {
                    l.Font = new Font(l.Font.Name, this.Height / 15);
                    l.Size = new Size(Width / 3, Height / 3);
                }
            }        private void Form1_Resize(object sender, EventArgs e)
            {
                Label[] labels = { label1, label2, label3, label4 };
                foreach (Label l in labels)
                {
                    l.Font = new Font(l.Font.Name, this.Height / 15);
                    l.Size = new Size(Width / 3, Height / 3);
                }
            }
        }
    }在界面上摆4个label,然后编写两个事件处理函数,如代码。
      

  2.   

    我想做成这个样子的,上下数据对应着,在改变对话框时lable成比例的改变,该怎么实现呢,谢谢
      

  3.   

    好像可以用 tablelayoutpanel 来实现布局,和你要的需求