更改RichTextBox的插入符号大小

时间:2015-06-02 10:07:34

标签: c# winforms

是否可以更改RichTextBox的插入符号大小?

我想更改Caret的Width

1 个答案:

答案 0 :(得分:-1)

你可以试试这个。

public partial class Form1 : Form
{
    [DllImport("user32.dll")]
    static extern bool CreateCaret(IntPtr hWnd, IntPtr hBitmap, int nWidth, int nHeight);
    [DllImport("user32.dll")]
    static extern bool ShowCaret(IntPtr hWnd);

    public Form1()
    {
        InitializeComponent();
    }


    private void richTextBox1_KeyUp(object sender, KeyEventArgs e)
    {
        CreateCaret(richTextBox1.Handle, IntPtr.Zero, 10, richTextBox1.Font.Height);
        ShowCaret(richTextBox1.Handle);

    }
}

Source