替换文本框中的字符 [英] replacing character in text box

查看:87
本文介绍了替换文本框中的字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个文本框,该文本框是通过IO流阅读器从文件填充的
我希望将textbox1中的文本转到textbox2中,但
我想做的是让在此textbox1中找到的每个{字符都在{字符后紧接一个换行符,并在下一行添加一个制表符.另外,它将在移动到textbox2之前或之时寻找}字符并在}字符后立即换行,但在}字符后没有制表符.我已经搜索了过去3个小时的google,但仍然没有找到我在看的string.Replace的解决方案,如果这种方法还没有找到方法.如果您有任何建议,请分享谢谢您的时间和上帝的祝福.

I have a text box that is populated from a file via IO stream reader
I want the text from textbox1 to go to textbox2 but
what i would like to do is have every { character that is found in this textbox1 have a line break immediately after the { character and a tab added to next line. Also it would look for the } character and make line break immediately after the } character but no tab after } character before or while it is being moved to textbox2. I have searched google for the last 3 hrs and still found no solution I was looking at the string.Replace and if this works have not found a way. If you have any suggestions please share Thank you for your time and god bless.

推荐答案

这应该有效:

This should work:

string text = textBox1.Text.Replace("{","{\\r\\n\\t");
textBox2.Text = text.Replace("}","}\\r\\n");



TextBox应该具有设置为true的multiline属性,才能正常工作.



The TextBox should have multiline property set to true for this to work.


此外,您还可以通过代码"clear();"添加名为"cleae"的"button click"它会取代您表单上的所有内容

谢谢你,祝你好运
Also you can add "button click" named "cleae" with the code " clear(); " in way u click it it will replace every thing on you form

thank you and good luck


这篇关于替换文本框中的字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆