I'm trying to print out the contents arr of objects, but all I get is a print out of my project name. I guess printing is working, but probably not correctly building my "result" so it can print out the contents. I don't really understand why, if someone can help me?

// Prints
    private void button2_Click(object sender, EventArgs e)
    {
      PrintPreviewDialog preview = new PrintPreviewDialog();
      PrintDocument recordDoc;
      // Create the document and name it
      recordDoc= new PrintDocument();
      recordDoc.PrintPage += new PrintPageEventHandler(this.PrintReceiptPage);
      // Preview document
      preview.Document = recordDoc;
      preview.ShowDialog();
      // Dispose of document when done printing
      recordDoc.Dispose();
  

    }

    private void PrintReceiptPage(object sender, PrintPageEventArgs e)

    {
      string result = "";
      // Print
      Font myFont = new Font("Courier", 12);

      for (int i = 0; i < arr.Length; i++)
      {
        result += Convert.ToString(arr[i]);
      }
     
      e.Graphics.DrawString(result , myFont, Brushes.Black, 0, 0);
    }

When I ran your code snippet I got a lot of zeros at the top left of the page.
Which is the expected result as I made arr an array of doubles.
Your problem is somewhere outside the code you have provided.

Possibly, page set-up means that the (0,0) location is outside the page clip region and your text is not printed.

Not sure how the project name is shown as you do not print this anywhere in your code.

Is this a Windows Forms Application?
What version of .Net are you targeting?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.