Insert tab when printing

1

I have a code to print each variable of a List . I'm trying to insert a tab in these variables. Take a look at my code that appears in the event printPage :

int charactersOnPage = 0;
int linesPerPage = 0;

var Fonte = new Font("Arial", 12);

Cliente cliente = Clientes[listaClientes.SelectedIndex];

StringBuilder sb = new StringBuilder();
foreach (var cli in cliente.Produtos)
{
    sb.AppendFormat("\n\n{0} R${1} Data: {2}", cli.NomeProduto, cli.ValorProduto, cli.DataCompra);
}

e.Graphics.MeasureString(sb.ToString(), Fonte, e.MarginBounds.Size, StringFormat.GenericTypographic, out charactersOnPage, out linesPerPage);

e.Graphics.DrawString(sb.ToString(), Fonte, Brushes.Black, e.MarginBounds, StringFormat.GenericTypographic);

e.HasMorePages = false;

With this code my output is something like: Carro R$20000 Data: 08/11/2014 . I want to insert a tab between these values and have this as output:

I've been trying things like:

RectangleF tabulacao = new RectangleF(30, 10, 100, 122);
e.Graphics.DrawString(System.Convert.ToString(sb), Fonte, Brushes.Blue, tabulacao);
e.Graphics.DrawRectangle(Pens.Black, Rectangle.Round(tabulacao));

I'm not sure how to organize each of these variables inside rectangles to do the tabulation. Any help is welcome!

    
asked by anonymous 09.11.2014 / 03:03

1 answer

1

I think the more certain you are to use some reporting tool.

But if you want to try to generate via HTML, for simple reports, up to one page is fine:
Put a WebBrowser in the window, and this code:

var HTML = "<html><body><table><tr><td>OK</td></tr></body></html>";
webBrowser.NavigateToString(HTML);
    
18.11.2014 / 23:43