C1PrintDocument

Posted by: friedrich on 20 April 2020, 7:27 am EST

    • Post Options:
    • Link

    Posted 20 April 2020, 7:27 am EST - Updated 3 October 2022, 11:59 pm EST

    I want to migrate a VS2019 PrintPreviewDialog to the better featured C1PrintPreviewDialog. The VS PrintPreviewDialog owned a PrintDocument and it is very easy to write a text and draw a line. See the result of this minimum 2 line code in the attached picture.

    Private Sub PrintDocument1_PrintPage(sender As Object, e As Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage

    Dim g As Graphics = e.Graphics

    g.DrawString(“Zu druckender Text”, New Font(“Courier New”, 12), Brushes.Black, 0, 0)

    g.DrawLine(New Pen(Color.Red, 5), 0, 0, 200, 200)

    End Sub

    Migrated to C1PrintDocument it is not possible to get a “Graphics” object from the “EventArg” parameter, where I can paint.

    Dim g As Graphics = e.Graphics

    “Graphics” is no Member from “EventArgs” !!!

    What lesson I have to learn, to understand the procedure?

    In the C1SampleExplorer I have nothing found?

    Where can I find simple samples to understand that all?

    Many thanks for each answer, Jürgen (Germany)

  • Posted 21 April 2020, 2:23 am EST

    Hi Jürgen,

    C1PrintDocument has some build-in RenderObject types to do the sample. You can look into the product sample “RenderObjects” implementing the same, the sample is located at:

    Documents\ComponentOne Samples\WinForms\v4.0\C1Preview\VB\RenderObjects

    https://www.grapecity.com/componentone/docs/win/online-report/C1.C1Report.4~C1.C1Preview.RenderObject.html?highlight=renderobject%2C

    If you need any other help then please let us know.

    Regards,

    Prabhat Sharma.

  • Posted 24 April 2020, 3:33 am EST

    Thank you Prabhat, the samples are helpful. I did not now, that they are exist at this location. Very important is the order to add the parts in the Form. It need to place the C1Preview control first. Then it shows the large text "Sample"as preview. After placing C1PrintDocument control it will show “C1PrintDocument1” as large text as preview. When place C1PrintDocument control first, there will be no conection to C1PreviewControl and it will continue to show “Sample” as preview. In properties of both samples I did not found a difference.

  • Posted 27 April 2020, 7:28 am EST

    Hi Jürgen,

    When placing the C1PrintDocument control after the C1Preview control, the Document property of the PrintPreview control is automatically set to C1PrintDocument that us why you are seeing the “C1PrintDocument1” as large text as a preview.

    In case of first placing C1PrintPreview control then C1PrintDocument control, you can set the Document property of C1PrintPreview control to C1PrintDocument to get the preview text as “C1PrintDocument1”.

    Regards,

    Prabhat Sharma.

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels