输出文本框中的文本而不是多行,在文本框属性中将换行设置为true
本文关键字:文本 属性 换行 true 设置 输出 | 更新日期: 2023-09-27 18:26:44
我需要winform的文本框是多行的,但我不知道怎么做。它只是一行。自动换行设置为true。我是否也必须在代码中设置为true?我是不是搞砸了格式?我不确定我做错了什么。这是代码:
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();
}
在windows中,您需要回车符和换行符来获取换行符。因此,在上面的示例中,您需要将每个''r''n都更改为一个。
此外,您可能没有设置"多行"特性。
尝试使用RichTextBox而不是Textbox