本文介绍了添加到字符串 - 清理方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我有一系列案例陈述,用于确定不可编辑文本框中每行的输出。这是非常复杂和混乱,所以我做了一个例子,而不是下面



我的第一个想法是将每个案例作为一个字符串:





I''ve got a series of case statements which determine the output of each line in a non editable textbox. It''s pretty complicated and messy so ive done an example instead below

My first idea was to just put each case as a string :

<pre lang="text">switch(x)
case(1): str1 = "hello";
case(2): str2 = "hi";
case(3): str3 = "bonjour";



问题是我的一些案例陈述有两个输出,而其他人有一个...即case(2)给出两个字符串,case(1)和case(3)输出一个字符串。



现在我知道我可以添加这些成一个字符串 - 但我不想。我需要在文本框中的单独行上。



我正在使用


The problem is some of my case statements have two outputs while others have one... ie case(2) gives two strings out while case(1) and case(3) output one string.

Now I know I could add these into one string - but I dont want to. I need these on seperate lines in a textbox.

I was using

this->textBox1->Text = "Greeting: " + str1 + Environment::NewLine +
// ... continues to next case table string outputs



但是正如我所说的,如果我有一些输出用于某些情况而另一个用于其他情况我不能使用它...



所以我的整体问题是如何在不覆盖当前文本的情况下为文本框设置新行?我知道你可以附加字符串,但你怎么做它所以它存储子串之间的换行符?



非常感谢


But as I said if I have two outputs for some cases and one for others I cant use this...

So my overall question is how can I set a new line for a textbox without overwriting the current text? I know you can append strings, but how do you do it so it stores the newline between substrings?

Many thanks

推荐答案




这篇关于添加到字符串 - 清理方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-30 12:40