1
I have a code to print each variable of a List
. I am trying to insert a tab into these variables. Take a look at my code that is 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 of mine output is something like: Carro R$20000 Data: 08/11/2014
. I want to insert a tab between these values and have as output this:
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 within rectangles to make the tabulation. Any help is welcome!
It is a report, which will be printed?
– Tony
Yes, all products purchased by the selected customer will be printed. My code is ready and the output as I want. The only thing I need is to insert a tab as in the example to be more organized.
– M. Victor
Tabulation using Rectanglef: you need to have at least one variable to control the displacement of the Rectanglef on the X axis
– Tony
Have you considered using any Reporting tool, or even HTML Tables to generate your report?
– Tony
I never associated C# with HTML. I think it’s a good idea.
– M. Victor