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