Help printing listview...my formatting needs work!
hello, i'm trying to print out the contents of a listview in an orderly fashion... i've got the contents all to print out, but getting them in nice columns like they appear on the listview control is proving to be a bigger challenge than i thought!
here is my code:
Code:
For i = 1 To lstStuff.ListItems.Count
Printer.Print lstStuff.ListItems(i); Tab(5); _
lstStuff.ListItems(i).SubItems(1); Tab(6); _
lstStuff.ListItems(i).SubItems(2); Tab(16); _
lstStuff.ListItems(i).SubItems(3); Tab(19); _
lstStuff.ListItems(i).SubItems(4); Tab(20); _
lstStuff.ListItems(i).SubItems(5); Tab(21); _
vbNewLine;
Next i
Printer.EndDoc
now that is printing out all the stuff in the columns of the first record in the list....
it seems it will only print in about a 2 inch margin on the left side of the page ?
here's how the output looks:
Name 3
Description $7.00
2
4 pm
when what it should look like is:
Name 3 Description $7.00 2 4pm
there should be 6 columns in there, but it's all gettin jumbled up... dunno if my tabbing is messed up, or if there's something else im doing wrong ... please help, im very novice when it comes to printing!
Believe it or not, I'm in the same boat as you are. I can't print the listview out at all, because I'm new to this stuff. Can you help me?
Dan Regalia [email protected] <-----USE THIS EMAIL ADDRESS PLEASE
I've done what your trying to do, unfortunately, it was months ago, and I don't have any of that code handy.
A few questions.
What does the vbNewLine do? Does it add a blank line? I haven't used that. If you remove it, the code should work with each Print command printing the list on a new line.
Are ; correct? This should be something really simple to check, and you are probably correct. I was thinking it was comma separated, but I think you're right.
That out of the way, perhaps your problem is as simple as the possibility that you are printing to an area that is 2" wide.
I don't specifically remember setting the print area on many of my programs, but you might check to see if the print area is set to something really small.
I was thinking, like, taking a screenshot of just the listview, but that would be cheating, right? And I guess the print would be kind of blur'ish, if you know what I mean.
I downloaded some code samples from planetsourcecode and found this quite interesting! Too bad it was to complicated for me . I didn't manage to extract just the code I need, but maybe one of you can?
what listview are you using, I know there are at least two in the components list and they act very differently.
microsoft windows common controls 6.0 (sp.4) is the one I use and my code for printing is identical to yours.
I cant remember what one the other one was under but it is very limited in uses. Hope this helps.