C#中主窗体Panel中加载其他多个窗体Panel控件
生活随笔
收集整理的這篇文章主要介紹了
C#中主窗体Panel中加载其他多个窗体Panel控件
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
今天在技術(shù)群里,筆者遇到一個這樣的問題,“有客戶想讓兩個Form窗體的內(nèi)容放到一個Form窗體中,但是兩個窗體的內(nèi)容超出主窗體的大小”,為了解決這個問題,筆者的想法是“采用panel+滑動條方式解決以上問題”,下面就跟筆者一起來看看。
首先,筆者寫了四個Form窗體,Form1為主窗體,Form2、Form3、Form4為子窗體
【主窗體】
【子窗體Form2】
【子窗體Form3】
【子窗體Form4】
三合一核心源碼
private void Form1_Load(object sender, EventArgs e){panel1.AutoScroll = true;//設(shè)置panel控件的自動滑動條//在主窗體panel中添加子窗體f2Form2 f2 = new Form2();f2.TopLevel = false;panel1.Controls.Add(f2);f2.Location = new System.Drawing.Point(0, 0);f2.Show();//在主窗體panel中添加子窗體f3Form3 f3 = new Form3();f3.TopLevel = false;panel1.Controls.Add(f3);f3.Location = new System.Drawing.Point(0, f2.Location.Y + f2.Height + 2);f3.Show();//在主窗體panel中添加子窗體f4Form4 f4 = new Form4();f4.TopLevel = false;panel1.Controls.Add(f4);f4.Location = new System.Drawing.Point(0, f3.Location.Y + f3.Height + 2);f4.Show();}三合一結(jié)果:
附加項目地址:
http://download.csdn.net/detail/lgh0824/9891099
總結(jié)
以上是生活随笔為你收集整理的C#中主窗体Panel中加载其他多个窗体Panel控件的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 2022年销量大跌!长城:深蹲是为了20
- 下一篇: C#时间与时间戳格式互相转化