【WinForm-无边框窗体】实现Panel移动窗体,没有边框的窗体
生活随笔
收集整理的這篇文章主要介紹了
【WinForm-无边框窗体】实现Panel移动窗体,没有边框的窗体
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
沒有邊框的窗體怎么移動(dòng)?其實(shí)方法有很多,下面介紹一種用控件來移動(dòng)窗體,Panel或PictureBox都可。主要設(shè)置控件的MouseDowm和MouseLeave事件。
第一步:窗體設(shè)計(jì)
窗體最上面是一個(gè)panel1
窗體最下面是一個(gè)Panel3,只顯示最上面一條線
?
第二步:panel移動(dòng)窗體實(shí)現(xiàn)代碼
MouseDown事件
MouseLeave事件
#region 移動(dòng)窗體Point downPoint;private void panel1_MouseDown(object sender, MouseEventArgs e){downPoint = new Point(e.X, e.Y);}private void panel1_MouseMove(object sender, MouseEventArgs e){if (e.Button == MouseButtons.Left){this.Location = new Point(this.Location.X + e.X - downPoint.X,this.Location.Y + e.Y - downPoint.Y);}}#endregion
如何實(shí)現(xiàn)panel只顯示最上面一條線?
Paint事件
//重繪panel3,只顯示最上面一條直線private void panel3_Paint(object sender, PaintEventArgs e){ControlPaint.DrawBorder(e.Graphics,this.panel3.ClientRectangle,Color.Lavender,1, ButtonBorderStyle.Dashed,Color.Gray,1,ButtonBorderStyle.Solid,Color.Lavender,1,ButtonBorderStyle.Dashed,Color.Lavender,1,ButtonBorderStyle.Dashed);}
轉(zhuǎn)載于:https://www.cnblogs.com/Sukie-s-home/p/5216980.html
總結(jié)
以上是生活随笔為你收集整理的【WinForm-无边框窗体】实现Panel移动窗体,没有边框的窗体的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 140.String Compressi
- 下一篇: angular5 接口跨域请求配置