Results 1 to 11 of 11

Thread: Help printing listview...my formatting needs work!

  1. #1

    Thread Starter
    Fanatic Member Redth's Avatar
    Join Date
    May 2001
    Location
    Ontario, Canada
    Posts
    551

    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!

  2. #2

    Thread Starter
    Fanatic Member Redth's Avatar
    Join Date
    May 2001
    Location
    Ontario, Canada
    Posts
    551
    somebody?

  3. #3
    Member
    Join Date
    Aug 2002
    Posts
    41

    Unhappy Hey Mate

    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

  4. #4
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,109
    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.

  5. #5
    Addicted Member Jakys's Avatar
    Join Date
    Dec 1999
    Location
    Norway
    Posts
    180
    Hi!
    I was just trying to do the same, here is my code:
    VB Code:
    1. With lView
    2.         For X = 1 To .ListItems.Count
    3.             Printer.Print .ListItems(X).Text & "   " & .ListItems(X).ListSubItems(1) & "   " & .ListItems(X).ListSubItems(2) & "   " & .ListItems(X).ListSubItems(3) & "   " & .ListItems(X).ListSubItems(4) & "   " & .ListItems(X).ListSubItems(5) & "   " & .ListItems(X).ListSubItems(6) & "   " & .ListItems(X).ListSubItems(7) & "   " & .ListItems(X).ListSubItems(8) & "   " & .ListItems(X).ListSubItems(9)
    4.         Next X
    5.     End With
    6.     Printer.EndDoc
    I got all the row's at one line, but the coloumns does not look so pretty.

    Hmm, why do i feel like my post is going to ruin the page width?
    MSN: [email protected]

    "Enhetssirkelen løser alle problemer" - ÅJT

  6. #6
    Addicted Member Jakys's Avatar
    Join Date
    Dec 1999
    Location
    Norway
    Posts
    180
    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?
    MSN: [email protected]

    "Enhetssirkelen løser alle problemer" - ÅJT

  7. #7
    Junior Member
    Join Date
    Apr 2002
    Location
    Michigan
    Posts
    27
    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.
    Rj

  8. #8
    Addicted Member Jakys's Avatar
    Join Date
    Dec 1999
    Location
    Norway
    Posts
    180
    You're sure it's not the ListBox you're talking about?
    MSN: [email protected]

    "Enhetssirkelen løser alle problemer" - ÅJT

  9. #9
    Fanatic Member
    Join Date
    Apr 2002
    Posts
    638
    i found this a while ago which worked well.
    Attached Files Attached Files

  10. #10
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

  11. #11
    Hyperactive Member
    Join Date
    Feb 2002
    Location
    Connecticut, USA
    Posts
    308
    Cool

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width