zoukankan      html  css  js  c++  java
  • C#实现控件随窗体拖动而自动缩放其大小

    C#代码:

      public  void AutoScale(Form frm)
            {
                frm.Tag = frm.Width.ToString() + "," + frm.Height.ToString();
                frm.SizeChanged += new EventHandler(frmScreen_SizeChanged);
            }

            private void frmScreen_SizeChanged(object sender, EventArgs e)
            {
                string[] tmp = ((Form)sender).Tag.ToString().Split(',');
                float width = (float)((Form)sender).Width / (float)Convert.ToInt16(tmp[0]);
                float heigth = (float)((Form)sender).Height / (float)Convert.ToInt16(tmp[1]);

                ((Form)sender).Tag = ((Form)sender).Width.ToString() + "," + ((Form)sender).Height;

                foreach (Control control in ((Form)sender).Controls)
                {
                    control.Scale(new SizeF(width, heigth));

                }
            }

           public frmScreen()
            {
                InitializeComponent();

                         AutoScale(this);
            }

  • 相关阅读:
    37. 解数独
    皮尔逊相关系数的计算以及数据的描述性统计
    商业微信小程序开发实战---1
    51. N皇后
    拟合算法
    216. 组合总和 III
    打印心性
    指针
    第五天
    循环 和 宏
  • 原文地址:https://www.cnblogs.com/yuxuan/p/1834448.html
Copyright © 2011-2022 走看看