Printing scrollable form

前端 未结 5 1915
面向向阳花
面向向阳花 2020-12-21 16:37

I have a scroll-able form which I would like to print entirely.

I have already tried using this code to print it:

    Private Sub btnPrint_Click(ByVa         


        
5条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-21 17:00

    In this line:

    PrintForm1.Print(Me, PowerPacks.Printing.PrintForm.PrintOption.Scrollable)
    

    It looks like PrintOption.Scrollable is only going to work, if you have a scrollable form. You have a scrollable control here (probably a Panel), inside a form. In this case its area will not be expanded onto the printer. Compare:

    Scrollable control:

    enter image description here

    prints as:

    enter image description here

    Scrollable form:

    enter image description here

    prints as:

    enter image description here

    According to this official answer from Microsoft, capturing a scrollable control is not possible with PrintForm. If you use a PrintDocument and some custom coding, you can do it for simple cases, such as a scrollable TextBox. In your case you may need even more custom coding to be done. Handling PrintDocument1.PrintPage looks like the best place to start, if you are up to it.

提交回复
热议问题