C# 在文本框中输出文本不是多行,在文本框属性中换行设置为true
我需要winform的文本框是多行的,但我不知道怎么做。它只是一行。Word wrap设置为true。我是否也必须在代码中将其设置为true?我是不是搞砸了我的格式?我不确定我做错了什么。代码如下:C# 在文本框中输出文本不是多行,在文本框属性中换行设置为true,c#,winforms,C#,Winforms,我需要winform的文本框是多行的,但我不知道怎么做。它只是一行。Word wrap设置为true。我是否也必须在代码中将其设置为true?我是不是搞砸了我的格式?我不确定我做错了什么。代码如下: public override string ToString() { return string.Format("{0} Pizzas @ {1:C}: {2:C}\n" + "{3} Cokes @ {4:C} {5:C}\n" +
public override string ToString()
{
return string.Format("{0} Pizzas @ {1:C}: {2:C}\n" +
"{3} Cokes @ {4:C} {5:C}\n" +
"Order Amount: {6:C}\n" +
"Sales Tax: {7:C}\n" +
"Amount Due: {8:C}\n" +
"Amount Paid: {9:C}\n" +
"Change Due: {10:C}", numberOfPizzas, PIZZA_PRICE,
totalCostOfPizza, numberOfCokes, COKE_PRICE, totalCostOfCoke,
foodAndDrinkTotal, totalSalesTax, totalAmountDue, amountPaid,
changeDue);
}
........
private void btnPaymentButton_Click(object sender, EventArgs e)
{
amountPaid = double.Parse(this.txtAmountPaid.Text);
orderPaymentObject = new Payment(orderObject.TotalAmountDue, amountPaid);
this.txtNumberOfPizzaOrdered.Clear();
this.txtNumberOfCokesOrdered.Clear();
this.txtAmountDue.Clear();
this.txtAmountPaid.Clear();
this.lblYourOrder.Visible = true;
this.txtYourOrder.Visible = true;
this.txtYourOrder.Text = orderObject.ToString();
}
尝试使用RichTextBox而不是Textbox尝试使用RichTextBox而不是Textbox在windows中,您需要回车符和换行符才能换行。因此,在上面的示例中,您需要将every\n更改为\r\n
此外,您可能尚未设置属性。在windows中,您需要回车符和换行符才能换行。因此,在上面的示例中,您需要将every\n更改为\r\n 此外,您可能尚未设置属性