【WinForm-无边框窗体】实现Panel移动窗体,没有边框的窗体
生活随笔
收集整理的這篇文章主要介紹了
【WinForm-无边框窗体】实现Panel移动窗体,没有边框的窗体
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
沒有邊框的窗體怎么移動?其實方法有很多,下面介紹一種用控件來移動窗體,Panel或PictureBox都可。主要設置控件的MouseDowm和MouseLeave事件。
第一步:窗體設計
窗體最上面是一個panel1
窗體最下面是一個Panel3,只顯示最上面一條線
?
第二步:panel移動窗體實現代碼
MouseDown事件
MouseLeave事件
#region 移動窗體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
如何實現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);}
轉載于:https://www.cnblogs.com/Sukie-s-home/p/5216980.html
總結
以上是生活随笔為你收集整理的【WinForm-无边框窗体】实现Panel移动窗体,没有边框的窗体的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 140.String Compressi
- 下一篇: angular5 接口跨域请求配置