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!