c# RTB - paste plain text without colours/fonts?

前端 未结 10 1362
感动是毒
感动是毒 2021-02-06 07:42

I am using Rich Text object in my C# application. The only issue I am having is that when user pastes formated text from another app, it remains formated which I cannot have. Is

10条回答
  •  星月不相逢
    2021-02-06 08:27

    You can also use

    private void richTextBox1_KeyDown(object sender, KeyEventArgs e)
    {
        if (e.Control && e.KeyCode == Keys.V)
        {
            richTextBox1.SelectedText = (string)Clipboard.GetData("Text");
            e.Handled = true;
        }
    }
    

提交回复
热议问题