none
Printing scrollable ListView with PrintForm component RRS feed

  • Question

  • I have been trying to use the new PrintForm component in VS2005 to print forms in my VB.NET Windows application.

    I am running into two problems:

    1) I can not print the content of a scrollable ListView. Let's say I have a ListView control on the form I want to print. I print the form using the following code:

    Me.Main_PrintForm.PrintAction = Printing.PrintAction.PrintToPrinter

    Me.Main_PrintForm.Print(Me.ActiveMdiChild, PowerPacks.Printing.PrintForm.PrintOption.FullWindow)

    which does print the form, but the content of the ListView is cut off to only the visible part of it. I want to print all the elements of the ListView including the ones that are not visible to the user that they would have to scroll down in the ListView control to see. I have tried using the Scrollable value for the second parameter in the Print method to no avail.

    Is it possible to print the whole content of a scrollable ListView control with the PrintForm component?

    2) How do I make it print in landscape format?

    Wednesday, January 3, 2007 9:44 PM

All replies

  • Anchor the ListView to the bottom of the form so it gets enlarged as the form is enlarged.  Print it like this:

      Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Me.AutoScroll = True
        Me.AutoScrollMinSize = New Size(0, Screen.PrimaryScreen.WorkingArea.Height)
        With PrintForm1
          .PrinterSettings.DefaultPageSettings.Landscape = True
          .Print(Me, PowerPacks.Printing.PrintForm.PrintOption.Scrollable)
        End With
        Me.AutoScroll = False
      End Sub

    If it still doesn't display all the items, you have no recourse but implement you own printing.
    Wednesday, January 3, 2007 10:16 PM
    Moderator
  • Nope, that didn't work. I guess I am suck with custom printing. Anyone know of any third-party controls out there that do something like that?
    Monday, January 8, 2007 7:53 PM