如何去掉TextBox可输入状态时的光标
2008-05-09 20:18
351 查看
c#中不能直接隐藏可编辑控件的光标的功能,真是奇怪!
只能通过WINDOWS API的HideCaret函数来实现
HideCaret函数的申明:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
[DllImport("user32", EntryPoint = "HideCaret")]
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
private static extern bool HideCaret(IntPtr hWnd);
为TextBox添加MouseDown事件:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
textbuttons[i].MouseDown += new MouseEventHandler(FrmSend_MouseDown);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
void FrmSend_MouseDown(object sender, MouseEventArgs e)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
//throw new Exception("The method or operation is not implemented.");
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
HideCaret(((TextBox)sender).Handle);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
}
只能通过WINDOWS API的HideCaret函数来实现
HideCaret函数的申明:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
[DllImport("user32", EntryPoint = "HideCaret")]
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
private static extern bool HideCaret(IntPtr hWnd);
为TextBox添加MouseDown事件:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
textbuttons[i].MouseDown += new MouseEventHandler(FrmSend_MouseDown);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
void FrmSend_MouseDown(object sender, MouseEventArgs e)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
//throw new Exception("The method or operation is not implemented.");
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
HideCaret(((TextBox)sender).Handle);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
相关文章推荐
- 如何:使 comboBox 输入状态变成 readonly 方式;TextBox 只读时的效果 (转载)
- 如何:使 comboBox 输入状态变成 readonly 方式;TextBox 只读时的效果;
- 如何:使 comboBox 输入状态变成 readonly 方式;TextBox 只读时的效果
- 如何:使 comboBox 输入状态变成 readonly 方式;TextBox 只读时的效果;
- 在javascript中如何获得textbox输入光标的位置
- 在javascript中如何获得textbox输入光标的位置
- C#如何让TEXTBOX只能输入英文状态下的数字并且限制位数
- winform textbox 输入状态下隐藏光标
- 如何得到 TextBox 或 richTextBox 的当前输入光标的屏幕坐标
- Asp.net如何验证TextBox控件只输入数字(五种情况分析)转帖
- WPF学习笔记-TextBox光标位置如何放到最后?
- DatePickerDialog 如何去掉输入时间标题也随之变化的效果
- 如何让telerikGridView控件变为可输入状态
- VB2005中如何设置光标状态
- 如何消除选定TextBox后的光标但又不失去焦点。
- asp.net 动态创建TextBox控件 如何加载状态信息
- Winform中怎样去掉TextBox输入回车时的警告音
- 如何验证TextBox输入的是一个日期格式字符串
- comboBox 输入状态变成 readonly 方式;TextBox 只读时的效果
- 将textbox中的光标移动到当前输入的文本后