【发布时间】:2017-07-30 13:11:43
【问题描述】:
void ClearAllRichtextboxes()
{
richTextBox3.Clear();
richTextBox5.Clear();
richTextBox6.Clear();
richTextBox9.Clear();
richTextBox10.Clear();
}
ClearAllRichtextboxes();
if (comboBox5.Text == "Primer")
{
richTextBox5.Text = "This is the number of primer tins" + primer.ToString();
richTextBox6.Text = "This is the cost of the primer tins" + primercost.ToString();
}
if (comboBox3.Text == "Matt")
{
richTextBox10.Text = "This is how many 2.5 tins of paint are needed: " + val44.ToString();
richTextBox9.Text = "This is the matt cost" + valmatt.ToString();
}
if (comboBox3.Text == "Vinyl ")
{
richTextBox10.Text = "This is how many 2.5 tins of paint are needed" + val44.ToString();
richTextBox9.Text = "This is the of vinyl cost" + valmatt.ToString();
}
if (comboBox3.Text =="Silk")
{
richTextBox10.Text = "This is how many 2.5 tins of paint are needed" + silkval.ToString();
richTextBox9.Text = "This is the cost: " + valcostsilk.ToString();
}
你好,我需要输出valcostsilk.ToStrin、silkval.ToStrin、valmatt.ToString、val44.ToString、val44.ToString的变量。几乎所有这些都只是一个富文本框。由于我是 c# 新手,所以我不知道。我在上一个帖子上问过,但我似乎无法得到我需要的答案。有人提到Enviorment.Newline,但我似乎无法正确编程。
任何帮助表示赞赏。
【问题讨论】:
-
有一个 RTB 方法
AppendText,是的,还添加了一个 Environment.NewLine。 -
你能给我一个例子让我开始吗?我现在正在尝试这样做,但它似乎不想为我这样做。
-
commonRTB.AppendText( "This is the number of primer tins" + primer.ToString() + Environment.NewLine); -
Environment.NewLine特定于代码执行的环境。例如,对于非 Unix 平台,这将获取包含“\r\n”的字符串,或者对于 Unix 平台,获取包含“\n”的字符串 - 所以它只是一个字符串,就像任何其他具有您想要的特定内容的字符串一样。跨度> -
您正在将基于两个组合框
comboBox3和comboBox5的文本(在您的 clear 方法中为空)替换为各种文本框。在一个地方做多件这样的事情似乎会让你感到困惑;这是真的吗?如果您为每个文本框创建一个StringBuilder,它也可能对您有所帮助,将它们设置为您希望文本框的内容,然后使用您拥有的每个文本框设置一次文本;帮助您更好地理解您的代码。
标签: c# variables richtextbox