天星直播

天星高清网络电视直播 http://www.3tvs.info 天星直播论坛 http://www.3tvs.info/bbs 天星影院 http://www.3tvs.info/yy
posts - 62, comments - 21, trackbacks - 0, articles - 0
  博客园 :: 首页 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理

公告

c#隐藏TextBox中闪烁的光标

Posted on 2011-05-31 11:22 hyruur 阅读(235) 评论(1) 编辑 收藏

方案:调用Windows API

1> 将TextBox的TabStop设置为false;

2> 在程序中相应位置加入下列代码

 

using System.Runtime.InteropServices;
……
[DllImport(
"user32", EntryPoint = "HideCaret")]
private static extern bool HideCaret(IntPtr hWnd);
……
在TextBox的MouseDown事件中添入:
HideCaret(((TextBox)sender).Handle);