I want to print the various variables of a List
. I am trying to use foreach
but it has not worked. The variables are written one over the other instead of a line break. Look at my code in the printPage event:
int charactersOnPage = 0;
int linesPerPage = 0;
var Fonte = new Font("Arial", 18);
Cliente cliente = Clientes[listaClientes.SelectedIndex];
foreach (var cli in cliente.Produtos)
{
string impressao = string.Format("Produto: {0}", cli.NomeProduto);
e.Graphics.MeasureString(impressao, Fonte, e.MarginBounds.Size, StringFormat.GenericTypographic, out charactersOnPage, out linesPerPage);
e.Graphics.DrawString(impressao, Fonte, Brushes.Black, e.MarginBounds, StringFormat.GenericTypographic);
impressao = impressao.Substring(charactersOnPage);
e.HasMorePages = false;
}
I need to output something like:
Produto: Carro
Produto: Bicicleta
With this my code, the products are all shuffled one on top of the other.
It's the first time I'm studying printing.