public void ReplaceSmileCode(String code, Bitmap bmp) { if (tb.InvokeRequired) { ReplaceSmileCodeCB d = new ReplaceSmileCodeCB(ReplaceSmileCode); try { tb.Parent.Invoke(d, new object[] { code, bmp }); } catch { } } else { int start = tb.Text.Substring(0).IndexOf(code); while (start > 0) { if (start > 0) { tb.SelectionStart = start; tb.SelectionLength = code.Length; //tb.Cut(); tb.InsertImage(bmp); } start = tb.Text.Substring(0).IndexOf(code); } } }
public void ReplaceSmileCode(String code, Bitmap bmp) { if (tb.InvokeRequired) { ReplaceSmileCodeCB d = new ReplaceSmileCodeCB(ReplaceSmileCode); try { tb.Parent.Invoke(d, new object[] { code,bmp }); } catch { } } else { int start = tb.Text.Substring(0).IndexOf(code); while (start > 0) { if (start > 0) { tb.SelectionStart = start; tb.SelectionLength = code.Length; //tb.Cut(); tb.InsertImage(bmp); } start = tb.Text.Substring(0).IndexOf(code); } } }