winform 可拖动的自定义Label控件
{
IsMouseDown = true;
MousePrePosition = new Point(e.X, e.Y);
this.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.Simple;
this.Cursor = Cursors.SizeAll;
}
{
IsMouseDown = false;
this.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.Default;
this.Cursor = Cursors.Default;
}
private void LabelModule_MouseMove(object sender, MouseEventArgs e)
{
if (!IsMouseDown) return;
this.Top = this.Top + (e.Y - MousePrePosition.Y);
this.Left = this.Left + (e.X - MousePrePosition.X);
}
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
namespace IJPrinterSoftware
{
public partial class LabelModule : LabelControl
{
private bool IsMouseDown = false;
private Point MousePrePosition;
private void init()
{
InitializeComponent();
this.MouseDown += new MouseEventHandler(LabelModule_MouseDown);
this.MouseUp += new MouseEventHandler(LabelModule_MouseUp);
this.MouseMove+=new MouseEventHandler(LabelModule_MouseMove);
}
public LabelModule()
{
init();
}
private void LabelModule_MouseDown(object sender, MouseEventArgs e)
{
IsMouseDown = true;
MousePrePosition = new Point(e.X, e.Y);
this.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.Simple;
this.Cursor = Cursors.SizeAll;
}
private void LabelModule_MouseUp(object sender, MouseEventArgs e)
{
IsMouseDown = false;
this.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.Default;
this.Cursor = Cursors.Default;
}
private void LabelModule_MouseMove(object sender, MouseEventArgs e)
{
if (!IsMouseDown) return;
this.Top = this.Top + (e.Y - MousePrePosition.Y);
this.Left = this.Left + (e.X - MousePrePosition.X);
}
}
}
版权声明:欢迎关注我的博客,本文为博主toyking原创文章,未经博主允许不得转载。
winform 可拖动的自定义Label控件的更多相关文章
- 自定义Label控件
最近开发过程中有一个需求就是修改label控件的模板,使其能够在鼠标移近的时候变成TextBox,从而方便输入,然后进行相应的修改,最终达到动态修改Label的目的,这里贴出相应的代码,并做简要的分析 ...
- winform学习(7)Label控件、Button控件、TextBox控件
Label控件是System.Windows.Forms.Label 类提供的控件. 作用:主要用来提供其他控件的描述文字,例如:登录窗体上的用户名.密码(输入框前面的字) Button控件是Syst ...
- C# winform自定义Label控件使其能设置行距
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.D ...
- C#Winform VScrollBar+Pannel自定义列表控件(原)
该控件的主要实现思路是用的objective-c中的自定义控件思路,主视图中放子视图 效果图 (窗体调用代码) public partial class Form1 : RibbonForm { Li ...
- Winform自定义键盘控件开发及使用
最近有学员提出项目中要使用键盘控件,系统自带的osk.exe不好用,于是就有了下面的内容: 首先是进行自定义键盘控件的开发,其实核心大家都知道,就是利用SendKeys.Send发送相应 的字符,但是 ...
- 在Winform界面使用自定义用户控件及TabelPanel和StackPanel布局控件
在很多时候,我们做一些非常规化的界面的时候,往往需要创建一些用户控件,在其中绘制好一些基础的界面块,作为后续重复使用的一个单元,用户控件同时也可以封装处理一些简单的逻辑.在开发Winform各种类型项 ...
- Label控件如何根据字符串自定义大小
一.. this.label_Msg.AutoSize = false; //设置label空件不能自动大小 二.. 用代码控制label控件的大小 1.根据字符串.label的宽度 计算字符串的面 ...
- WinForm使用Label控件模拟分割线(竖向)
用Label控件进行模拟 宽度设为1:this.lblPagerSpliter1.Size = new System.Drawing.Size(1, 21); 去掉边框:this.lblPagerSp ...
- [WinForm]WinForm跨线程UI操作常用控件类大全
前言 在C#开发的WinForm窗体程序开发的时候,经常会使用多线程处理一些比较耗时之类的操作.不过会有一个问题:就是涉及到跨线程操作UI元素. 相信才开始接触的人一定会遇上这个问题. 为了解决这个问 ...
随机推荐
- 电子商务中:B2C、B2B、C2B、C2C、O2O、P2P
c2c实际是电子商务的专业用语,是个人与个人之间的电子商务.比如一个消费者有一台电脑,通过网络进行交易,把它出售给另外一个消费者,此种交易类型就称为C2C电子商务.淘宝是属于C2C模式的. c2 ...
- Scalaz(20)-Monad: Validation-Applicative版本的Either
scalaz还提供了个type class叫Validation.乍看起来跟\/没什么分别.实际上这个Validation是在\/的基础上增加了Applicative功能,就是实现了ap函数.通过Ap ...
- TestNG官方文档中文版(1)-介绍
TestNG的官方文档请见: http://testng.org/doc/documentation-main.html 1. 介绍 TestNG是一个设计用来简化广泛的测试需求的测试框架,从单 ...
- svg-高斯模糊+swiper伦播
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...
- Javascript 语言精粹 代码片段合集
Javascript 语言精粹 代码片段合集 标签:Douglas-Crockford Javascript 最佳实践 原文链接 更好的阅读体验 使用一个method 方法定义新方法 Function ...
- Horseman - 让你更轻松的使用 PhantomJS
Horseman 是一个 Node.js 模块,让你可以更轻松的使用 PhantomJS 进行功能测试,页面自动机,网络监控,屏幕捕获等.它提供了直接,链式的 API,易于理解的控制流,避免回调陷阱. ...
- ae开发基础功能
放大.缩小.pan.框选要素(新建命令,建立命令HOOK,赋给当前地图控件): ICommand cmd = new ControlsSelectFeaturesTool(); cmd.OnCreat ...
- 读取SHP的投影信息
from osgeo import ogr shp_driver = ogr.GetDriverByName('ESRI Shapefile') shp_dataset = shp_driver.Op ...
- atitit.数据验证--db数据库数据验证约束
atitit.数据验证--db数据库数据验证约束 1. 为了加强账户数据金额的安全性,需要增加验证字段..1 2. 创建帐户1 3. 更改账户2 4. ---code3 5. --fini4 1. 为 ...
- Thoughts on an Article from Science 'A network framework of cultural history'
Apparently, this is an excellent interdisciplinary study. This paper drawn on a simple but large dat ...