c# 界面自适应大小


采用在窗体事件SizeChanged里面代码控制大小和位置,达到自动适应窗体大小,这样做调整起来方便。  

    private void FrmMain_SizeChanged(object sender, EventArgs e)
        {
            //int grpLogWidth = (this.Width * 42) / 100;
            //int tabControlWidth = this.Width - grpLogWidth;

            
            int tabControlWidth = tabControl.Width;
            int grpLogWidth = this.Width - tabControl.Width-50;

            grpLog.Height = this.Height - 100;
            rtxtLog.Height = grpLog.Height - 60;
            grpLog.Width = grpLogWidth;
            rtxtLog.Width = grpLogWidth - 10;

            tabControl.Location = new Point(grpLogWidth + 20, tabControl.Location.Y);
            tabControl.Height = grpLog.Height - 10;
            dgvCalibration.Height = tabControl.Height - 70;            
        }

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM