How to print tabs

  • Thread starter Thread starter E. W via DotNetMonster.com
  • Start date Start date
E

E. W via DotNetMonster.com

Hi,
I have to print Datagrids (result of DB-Queries) as well formed as seen on
the screen.
So I use tab-signs to seperate the columns and create a file. But the tabs
are not printed (only a space) when I print this file (via PrintDocument.
Print()). What's wrong?
thanks
ew
 
Hello,

I don't think Tab characters will be printed as fixed-width spaces. You will
have to handle them manually (manually move the print position). Example:

In the PrintPageEventHandler:

Font f; // Font to be used
float x, y; // Print positions
StringFormat sf = new StringFormat();
string textToPrint = "Sample Text";
....
PrintPageEventArgs.Graphics.DrawString (textToPrint, f, Brushes.Orange, x,
y, sf);
// ASCII 9 is Tab
x += PrintPageEventArgs.Graphics.MeasureString (Convert.ToString((char)9) +
textToPrint, f).Width;
// Prints after a 'tab'
PrintPageEventArgs.Graphics.DrawString (textToPrint, f, Brushes.Orange, x,
y, sf);

Hope this helps?


Hi,
I have to print Datagrids (result of DB-Queries) as well formed as seen on
the screen.
So I use tab-signs to seperate the columns and create a file. But the tabs
are not printed (only a space) when I print this file (via PrintDocument.
Print()). What's wrong?
thanks
ew
 
thanks,
I tried an other possibility and used SetTabStops-Method in StringFormat
ew
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top