5

A simple question :) how do I insert icons into a richtextbox.

For example I want " :-) " to be replaced by, say, ImageList[1] ?

Thanks!

abatishchev
  • 98,240
  • 88
  • 296
  • 433
Roger
  • 6,443
  • 20
  • 61
  • 88

1 Answers1

2

I think only way is using Paste option.

Try this code

    private void richTextBox1_KeyDown(object sender, KeyEventArgs e)
{
    if (richTextBox1.Text.Contains(":-)"))
    {
        richTextBox1.SelectionStart = richTextBox1.Find(":-)", RichTextBoxFinds.WholeWord);
        richTextBox1.SelectionLength = 3;

        Clipboard.SetImage(im.Images["smile.png"]);
        this.richTextBox1.Paste();
    }
}
Anuraj
  • 18,859
  • 7
  • 53
  • 79