Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Printing treeviews

Status
Not open for further replies.

vinemicros

Programmer
Apr 4, 2001
12
GB
Does anyone know of a good way of printing Microsoft Treeview controls?

I've successfully done it by turning the treeview into a cursor (using .parent. and .child., etc. to scan through the tree, and adding spaces and arrows at suitable points), but the problem is how to get the tree elements to line up in the printout properly.

My only solution was to use the Courier typeface, which of course is not a proportional font, and thus every character is the same width. This makes it easy for my routine to indent things by the right amount, but looks nasty on a printout.

I'm sure there's a solution somewhere, but I can't find it.
 
Hi!

You can also use following technique:
Add several controls at the same place, but each shifted by required number of points for each level of the tree nodes. In the table have a field that represents a level of the node in the tree. In the controls use "Print When..." option and print each control only in case control is proper for level of node in current record. This way you will be able to use any font.
There are other technique - use TXTWidth() function to calculate number of spaces required to add to the node text to shift it properly. If done correctly, you will need only 4 controls shifted by 1-2 points each with proepr 'Print When...'. This is more complex, but less controls used.

Vlad Grynchyshyn
vgryn@softserve.lviv.ua
The professional level of programmer could be determined by level of stupidity of his/her bugs
 
Thanks Vlad, I've now used the TXTWIDTH() function to figure out what other characters are the same width as spaces (ie. [ ] \ - ). This has let me modify my code, so that even using proportional fonts will not muck up the indenting.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top