Click here to Skip to main content
15,921,990 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
private void txtLog_TextChanged(object sender, EventArgs e)
        {
            Image img = Image.FromFile("C:/Dokumente und Einstellungen/mgmeiner/Desktop/smile3.gif");
            string smile1 = ":)";
            if (txtLog.Text.Contains(smile1))
            {
                txtLog.Text = txtLog.Text.Replace(":)", Clipboard.SetImage(img));
            }
        }


But this doesn't work!
Posted

That's because it's a textbox and not a default placeholder for images. You would have to draw the control yourself and when you encounter the sequence ":)" you wouldn't draw the letters but the image instead. There is some more work to it than simply replacing a text sequence by an image. You are now mixing different types that do not apply.

You could however use an rtf control that already has implementation for this, have a look here:

http://www.codeproject.com/KB/edit/csexrichtextbox.asp[^]

Good luck!
 
Share this answer
 
Hi,

Try using Rich Textbox control...

There are some posts in the net... See this... http://www.daniweb.com/forums/thread25861.html[^]

Regards,
Suresh
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900