我正在尝试在富文本框中显示以下内容。这就是我想要展示的内容
//“计算”按钮计算总薪资,税金和净工资,然后使用富文本框中各种金额的货币格式显示姓名,部门,工资总额,税金和净工资
这些是在代码的开头声明的:
**private const decimal TAX = 0.25m;
private string name="";**
这是计算按钮:
private void CalcButton_Click(object sender, EventArgs e)
{
// Gross pay= (hours * rate)
// Taxes= (25% of gross pay)
// Net pay (gross pay ?taxes)
decimal Gross_pay;
decimal Taxes;
decimal Net_Pay;
decimal annual_salary;
//calculate
Gross_pay = Convert.ToInt32(HoursTextBox.Text) * decimal.Parse(RateTextBox.Text);
Taxes = TAX * Gross_pay;
Net_Pay = Gross_pay - Taxes;
annual_salary = Net_Pay;
//display
DisplayOutPut.Text = NameTextBox.Text;
DisplayOutPut.Text = HoursTextBox.Text;
DisplayOutPut.Text = RateTextBox.Text;
DisplayOutPut.Text = Gross_pay.ToString("C"); // Hours*Rate
DisplayOutPut.Text= Taxes.ToString("C");
DisplayOutPut.Text= Net_Pay.ToString("C");
答案 0 :(得分:1)
使用AppendText并添加NewLine
DisplayOutPut.AppendText(NameTextBox.Text);
DisplayOutPut.AppendText(Environment.NewLine);
DisplayOutPut.AppendText(HoursTextBox.Text);
DisplayOutPut.AppendText(Environment.NewLine);
DisplayOutPut.AppendText(RateTextBox.Text);
DisplayOutPut.AppendText(Environment.NewLine);
DisplayOutPut.AppendText(Gross_pay.ToString("C")); // Hours*Rate
DisplayOutPut.AppendText(Environment.NewLine);
DisplayOutPut.AppendText(Taxes.ToString("C"));
DisplayOutPut.AppendText(Environment.NewLine);
DisplayOutPut.AppendText(Net_Pay.ToString("C"));