473,406 Members | 2,259 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

How to print tabs


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
--
Message posted via DotNetMonster.com
http://www.dotnetmonster.com/Uwe/For...sharp/200507/1
Nov 17 '05 #1
2 8444
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?

"E. W via DotNetMonster.com" <fo***@DotNetMonster.com> wrote in message
news:51***********@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
--
Message posted via DotNetMonster.com
http://www.dotnetmonster.com/Uwe/For...sharp/200507/1
Nov 17 '05 #2

thanks,
I tried an other possibility and used SetTabStops-Method in StringFormat
ew
--
Message posted via DotNetMonster.com
http://www.dotnetmonster.com/Uwe/For...sharp/200507/1
Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Steve Richter | last post by:
in the vs studio editor, I change the tab indent from 4 to 2. And my C# code displays with 2 characters per indent level instead of 4. But when I print, the indent is back to 4. also, when a...
2
by: Rob | last post by:
I have a webform that uses the TabStrip and MultiPage webcontrols. I also have a Print button on the form to print all of the information of the webform (all tabs): <input type="button"...
2
by: qwweeeit | last post by:
Hi all, from a string embedding tabs I want to colorize them when expanded: # Starting from a string: a= '1234\t5678\t\t90\nqwerty\nasdfg' # which embeds both tabs and lfs # printing it you...
2
by: qwweeeit | last post by:
Hi all, in a previous post I asked help for colorizing expanded tab. I wanted to list text files showing in colors LFs and the expanded tabs. I hoped to use only bash but, being impossible, I...
135
by: Xah Lee | last post by:
Tabs versus Spaces in Source Code Xah Lee, 2006-05-13 In coding a computer program, there's often the choices of tabs or spaces for code indentation. There is a large amount of confusion about...
15
by: Tom Plunket | last post by:
The documentation for dedent says, "Remove any whitespace than can be uniformly removed from the left of every line in `text`", yet I'm finding that it's also modifying the '\t' characters, which...
69
by: Edward K Ream | last post by:
The pros and cons of making 'print' a function in Python 3.x are well discussed at: http://mail.python.org/pipermail/python-dev/2005-September/056154.html Alas, it appears that the effect of...
4
by: John Nagle | last post by:
One can argue over tab vs. space indentation, but mixing the two is just wrong. Why not have CPython report an error if a file has both leading tabs and leading spaces? I know that was proposed...
12
by: ibloom | last post by:
I've been trying for a couple days to build a program using pyObjC on a mac, I'm stuck on this error: <string>: inconsistent use of tabs and spaces in indentation Traceback (most recent call...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.