C#如何将表情符号添加到richtextbox,winform [英] C# how can I add emoticons to richtextbox, winform
本文介绍了C#如何将表情符号添加到richtextbox,winform的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Hashtable emotions;
private void CreateEmotions()
{
emotions = new Hashtable(12);
emotions.Add(@":)", Properties.Resources.ThumbsUp1);
emotions.Add(@"0)", Properties.Resources.AngelSmile1);
emotions.Add(@":(", Properties.Resources.CrySmile1);
emotions.Add(@":X", Properties.Resources.AngrySmile1);
emotions.Add(@"XX", Properties.Resources.DevilSmile);
}
private void AddEmotions(Hashtable emotions)
{
foreach (string emote in emotions.Keys)
while (txtLoad.Text.Contains(emote))
{
int ind = txtLoad.Text.IndexOf(emote);
txtLoad.Select(ind, emote.Length);
Clipboard.SetImage((Image)emotions[emote]);
txtLoad.Paste();
}
}
我正在使用这些代码行插入表情符号进入我的richtextbox但是当我发送信息时它会显示我输入的内容而不是图像。
I am using these lines of code to insert smileys into my richtextbox but when I send the message it shows what I type and not the image.
if (msgReceived.strMessage != null && msgReceived.cmdCommand !=Command.List)
txtLoad.Text += msgReceived.strMessage + "\r\n";
该代码设置richtextbox文本,添加用户输入的消息。
我尝试过:
在线寻找帮助,以及其他示例......
That code sets the richtextbox text, adds the messages typed by the users.
What I have tried:
Looking for help online, and other examples...
推荐答案
不确定你真正搜索了多少,因为这篇文章很容易找到。
在运行时将纯文本和图像插入RichTextBox [ ^ ]
我认为这就是你要找的东西。
Not sure how much you really searched, because this article was easy enough to find.
Insert Plain Text and Images into RichTextBox at Runtime[^]
I think this is what you are looking for.
这篇关于C#如何将表情符号添加到richtextbox,winform的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文