本文介绍了富文本框文本用另一个单词替换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何用"happy"之类的单词替换"::"之类的文本通道.

这是一些代码,但是不起作用!

How can i replace a textpassage like: ":)" with a word like "happy".

Here is some code but it doesn''t work!

private void txtLog_TextChanged(object sender, EventArgs e)
        {
            string smile1 = ":)";
            if (txtLog.Text == smile1)
            {
                smile1.Replace(":)", "Happy");
            }
        }

推荐答案

private void txtLog_TextChanged(object sender, EventArgs e)        {
    string smile1 = ":)";
    if (txtLog.Text.Contains(smile1))
    {
        txtLog.Text = txtLog.Text.Replace(":)", "Happy");
    }
}



为什么还要问这个问题???:confused :: confused :: confused:



Why even ask the question ???:confused::confused::confused:


这篇关于富文本框文本用另一个单词替换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-22 23:46