2009-05-21 65 views

回答

1

你可以的PInvoke CreateCaret

的例子使用一个WinForm一个按钮(按钮1)和文本框(textBox1中)做到这一点。

添加此使用指令:

using System.Runtime.InteropServices; 

添加这些声明:

[DllImport("user32.dll")] 
static extern bool CreateCaret(IntPtr hWnd, IntPtr hBitmap, int nWidth, int nHeight); 
[DllImport("user32.dll")] 
static extern bool ShowCaret(IntPtr hWnd); 

这个代码添加到按钮单击事件:

// Thickness is set where I have 10. 
    CreateCaret(textBox1.Handle, IntPtr.Zero, 10, textBox1.Height); 
    ShowCaret(textBox1.Handle); 

当您点击按钮”会得到一个更粗的光标。

还有关于这个here的讨论。

+0

真棒谢谢...现在我知道要搜索什么,我看他们是如何调用这个。其实......这是一个肯定的日常WF赢家 – 2009-05-21 18:30:45