Syntax_Error
Syntax_Error

Reputation: 101

Displaying stuff in a rich text box

I'm trying to display the following in a rich text box. This is what I'm trying to display

// The “Calculate” button calculates gross pay, taxes, and net pay and then displays name, department, gross pay, taxes, and net pay using currency format for various amounts in the rich text box

These are declared at the beginning of the code:

      **private const decimal TAX = 0.25m;
      private string name="";**

This is the calculate button:

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");

Upvotes: 0

Views: 4365

Answers (1)

rene
rene

Reputation: 42494

Use AppendText and add a 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"));

Upvotes: 1

Related Questions