C# 带滚动栏的Label控件,用鼠标选的时候还是有点闪烁:

namespace 带滚动栏的Label控件
{
public class TextBoxLabel : System.Windows.Forms.TextBox
{
[DllImport("user32", EntryPoint = "HideCaret")]
private static extern bool HideCaret(IntPtr hWnd); [DllImport("user32", EntryPoint = "ShowCaret")]
private static extern bool ShowCaret(IntPtr hWnd); public TextBoxLabel():base(){ this.TabStop = false;
this.SetStyle(ControlStyles.Selectable, false);
this.Cursor = Cursors.Default;
this.ReadOnly = true;
this.ShortcutsEnabled = false;
this.HideSelection = true;
this.GotFocus += new EventHandler(TextBoxLabel_GotFocus);
this.MouseMove += new MouseEventHandler(TextBoxLabel_MouseMove);
} private void TextBoxLabel_GotFocus(Object sender, System.EventArgs e){
if (ShowCaret(((TextBox)sender).Handle)){
HideCaret(((TextBox)sender).Handle);
}
} private void TextBoxLabel_MouseMove(Object sender, MouseEventArgs e){
if (((TextBox)sender).SelectedText.Length > 0){
((TextBox)sender).SelectionLength = 0;
}
}
}
}

效果:

实现思路及用途參考:http://bbs.csdn.net/topics/390632325?page=1#post-398542672

最新文章

  1. iOS开发之功能模块--高仿Boss直聘的IM界面交互功能
  2. 圆角卖萌式登录表单和width的百分比值
  3. Runtime.exec() sucks!!!!
  4. dropdownlist 动态添加
  5. 将框架的底层改掉,改成一个轻量级的ORM
  6. php flush()刷新不能输出缓冲的原因分析
  7. 1-3-1 关于API
  8. udp 视频包网络传输花屏
  9. HtmlAgilityPack.dll的使用 获取HTMLid
  10. C# 该行已经属于另一个表 的解决方法[转]
  11. 记录一次Jmeter性能测试
  12. python3中str的函数
  13. 将spring cloud打包docker镜像
  14. JAVA之JDBC的简单使用(Mysql)
  15. 记录一下,PC端vue开发常用框架,已经用过elementUI和iview 接下来尝试另一个Muse-UI 喜欢它的点击效果
  16. Lombok使用简介
  17. iphone弹出窗口效果的制作(Core animation, CALayer)
  18. [WC2014]时空穿梭(莫比乌斯反演)
  19. Python练习笔记——通讯录查询V1.0
  20. IntelliJ IDEA 14 利用JRebel实现热部署

热门文章

  1. JAVA设计模式--辛格尔顿
  2. Spring aop 小例子demo
  3. JUnit实战(2) - JUnit核心(使用Suite来组合测试)
  4. Dev GridView RowCellClick活动MouseDown事件
  5. PC结束 Spark 二次开发 收到自己主动,并允许好友请求
  6. 在Jenkins中配置运行远程shell命令
  7. ABP应用层——数据传输对象(DTOs)
  8. SQL Server 备份和还原全攻略
  9. OBIEE SampleAppv406 自己主动启动配置
  10. BZOJ 1010: [HNOI2008]玩具包装toy