博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
【WinForm-无边框窗体】实现Panel移动窗体,没有边框的窗体
阅读量:4640 次
发布时间:2019-06-09

本文共 1146 字,大约阅读时间需要 3 分钟。

没有边框的窗体怎么移动?其实方法有很多,下面介绍一种用控件来移动窗体,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

你可能感兴趣的文章
Java生鲜电商平台-Linux服务器常用升级的基础包
查看>>
聊天室(C++客户端+Pyhton服务器)2.基本功能添加
查看>>
swift中try
查看>>
缓存框架Ehcache相关
查看>>
用Instant client批量安装Oracle客户端-安装配置
查看>>
Fireworks为枝繁叶茂的树木图片抠底
查看>>
iphone 开发学习整理
查看>>
自我介绍
查看>>
Prof. Dr. Ligang Liu (刘利刚) 中国科技大学
查看>>
centos 升级openssl
查看>>
Ubuntu下安装 Mono(整理)
查看>>
Python Tkinter 学习成果:点歌软件music
查看>>
虚方法(virtual)和抽象方法(abstract)的区别
查看>>
Guid.NewGuid().ToString()生成唯一码js
查看>>
python 中feedParser
查看>>
提高网站用户体验的4个方面
查看>>
内联函数和宏
查看>>
SpringMVC存取Session的两种方法
查看>>
Solution 27:跳台阶问题
查看>>
Docker-----常用命令
查看>>