Results 1 to 6 of 6

Thread: Print ListView

  1. #1

    Thread Starter
    Fanatic Member vbPoet's Avatar
    Join Date
    Feb 2005
    Location
    Searching ..
    Posts
    669

    Print ListView

    I want to print contents in Listview..
    can u please guide me..?

  2. #2

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

    Re: Print ListView

    This is a piece of code originally posted by MartinLiss (I don't have the actual link) that I've found very useful in the past.
    VB Code:
    1. Private Sub Command1_Click()
    2. Dim i As Long
    3. Printer.FontName = "arial"
    4.     Printer.FontUnderline = True
    5.     Printer.FontSize = 8
    6.     Printer.Orientation = vbPRORLandscape
    7.     Printer.Print "Lineitem"; _
    8.                   Tab(30); "Description"; _
    9.                   Tab(100); "Location"
    10.     Printer.FontUnderline = False
    11.    
    12.     For i = 1 To ListView1.ListItems.Count
    13.         Printer.Print ListView1.ListItems(i); _
    14.                       Tab(30); ListView1.ListItems(i).ListSubItems(1); _
    15.                       Tab(100); ListView1.ListItems(i).ListSubItems(2)
    16.     Next
    17.    
    18.     Printer.EndDoc
    19. End Sub
    It needs to be tweaked for each individual ListView, but that usually doesn't require a whole lot of work.

  4. #4

    Thread Starter
    Fanatic Member vbPoet's Avatar
    Join Date
    Feb 2005
    Location
    Searching ..
    Posts
    669

    Re: Print ListView

    MR HACK
    first Congratulation for being Most Valuable Professional


    your code alias Martin sounds gr8.
    Is there any genuine method..
    that we just pass Cotrol name (* here in my problem ListView1 *)
    I mean any kind of API ..>?
    or something else more tricky.

  5. #5
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: Print ListView

    Put that code in a function with a LISTVIEW argument - pass in the LISTVIEW you want to process.

    That way it's a single function for all list views.

    I would personally not use the TAB statement but instead find out the width of the listview columns and set the .CURRENTX value to move the print position along the line.

    We do that for printing flexgrids - works very nicely.

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  6. #6

    Thread Starter
    Fanatic Member vbPoet's Avatar
    Join Date
    Feb 2005
    Location
    Searching ..
    Posts
    669

    Re: Print ListView

    Quote Originally Posted by vbPoet
    I mean any kind of API ..>?
    or something else more tricky.
    there could be another option....

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