Results 1 to 7 of 7

Thread: How to print content of a Multi column Listbox?

  1. #1
    Join Date
    Jun 2011
    Posts
    91

    How to print content of a Multi column Listbox?

    Lately I have been trying to print multi column Listbox, I have used multiple colored cells with complete screen control. I came to know about ListBox printer created by Alex Restrepo, My question is how we suppose to use it and I haven’t found any documentation related to it. What listbox to print? Also let me know how I am supposed to use the class or any better alternative idea. Any help will be appreciated.

  2. #2
    Join Date
    Apr 2009
    Posts
    488

    Re: How to print content of a Multi column Listbox?

    In a project a Listbox Printer instance or widget is set on the window to get event. If you want headers than the only other option I see is to fill in the DrawHeader. Just have a look in the project at Window1. To print, it will appear to beas simple as below:

    Code:
    dim lbPrinter As new ListboxPrinter
    lbPrinter.print(Listbox1, true)       
    //true does some fitWidth thing

  3. #3
    Join Date
    Nov 2008
    Posts
    996

    Re: How to print content of a Multi column Listbox?

    Alex provides a basis for printing the contents of a list box. And he did a good job for it. To do what you are asking requires a lot of additional code beyond what can be explained in a response to a question on the forum. There is much to be considered to go beyond what you provide. What if a line exceeds the width of a page, even if the excess width of the columns is removed from one. Now it is up to you to try to add what you desire on your point of departure. It will be easier for people from another forum to help the kids with requests for help when problems arise.

  4. #4
    Join Date
    May 2008
    Posts
    979

    Re: How to print content of a Multi column Listbox?

    ListBox printer has been created by Alex Restrepo. So according to Alex you will need to modify the Printer setup object in the print method for margins and give appropriate margins.
    Here is the Print Method:

    Code:
     dim printer as graphics
      dim setup as printerSetup
      dim totalWidth as integer
      dim row, column as integer
      dim columnScale as single
      dim sx, sy, w, h, maxH, xs(), i as integer
      
      self.source=source
      
      setup=new printerSetup
      if setup.PageSetupDialog then
        printer=openprinterDialog(setup)
        if printer<>nil then
          
          if fitWidth then
            //find total width
            for row=0 to source.columncount-1
              totalWidth=totalWidth+source.column(row).widthActual 
            next
            columnScale=setup.width/totalWidth
          else
            columnScale=1
          end if
          
          sx=0
          sy = self.printHeaders(0,printer,columnscale,xs)+3
          for row=0 to source.listcount-1
            for column=0 to source.columncount-1
              w=source.column(column).widthActual*columnScale
              'self.printCell(row,column,printer,sx,sy,w,h)
              self.printCell(row,column,printer,xs(column),sy,w,h)
              if h>maxH then maxH=h
            next
            sx=0
            sy=sy+maxH+2
            maxH=0
            
            if sy+printer.textascent>setup.height then
              for i=0 to ubound(xs)
                printer.foreColor=lineColor
                printer.drawline xs(i),headerHeight,xs(i),printer.height
                printer.foreColor=textcolor
              next
              printer.nextPage
              sy=self.printHeaders(0,printer,columnscale,xs)+3
            end if
          next
          
          for i=0 to ubound(xs)
            printer.foreColor=linecolor
            printer.drawline xs(i),headerHeight,xs(i),printer.height
            printer.foreColor=textcolor
          next
          
        end if
      end if

  5. #5
    Join Date
    Nov 2008
    Posts
    1,054

    Re: How to print content of a Multi column Listbox?

    As per my knowledge the margins should be adjusted in code. I can’t expect the user to have adjusted the margins by themselves for correct printout with proper margins. It would be a drawback and the user won’t do that if that is the case. You have to adjust the ‘X’ and ‘Y’ co-ordinates using appropriate code if possible. That is what the Alex Restrepo meant by modifying the printer setup object in the print method. I hope the information that I have provided to you helps you.

  6. #6
    Join Date
    May 2008
    Posts
    913

    Re: How to print content of a Multi column Listbox?

    As the class PageLeft PrinterSetup you have owned and this gives the number of pixels from the left edge of paper printing start if x = 0 is used (the left). Home Page gives you the number of pixels from the edge of the paper print if used and g.textascent = its value and heading (top margin). You need to check these values and decide whether or not to increase before start printing.

  7. #7
    Join Date
    May 2009
    Posts
    637

    Re: How to print content of a Multi column Listbox?

    The impression is one of the most complicated programming. Because of this, if you expect to find a code that is able to be included in the payment of a decent amount of money for it since he had plenty of time for the author to achieve. If you want larger margins top and left and then increase the x values and looking, but we must also consider the full width of the columns, the resolution of the printer used so you can scale things well, the paper size and a lot of other elements to complete success. Sounds easy, but is not as easy as it looks when viewed in the paper.

Similar Threads

  1. Replies: 4
    Last Post: 28-01-2012, 03:45 PM
  2. How do I print a folder content LIST not using "print screen"?
    By pushpendra in forum MS Office Support
    Replies: 3
    Last Post: 26-07-2010, 03:53 PM
  3. Print a selection of cells in MS Excel (row / column)?
    By mikey32 in forum Windows Software
    Replies: 3
    Last Post: 10-03-2009, 07:28 PM
  4. How to create multi-column combo box in vb.net?
    By ShonaliB in forum Software Development
    Replies: 2
    Last Post: 26-02-2009, 10:45 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,896,498.14991 seconds with 17 queries