Results 1 to 4 of 4

Thread: Printing the contents of a specific control

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2021
    Posts
    10

    Printing the contents of a specific control

    Hello, I have used PrintDocument Class to print my entire form before, is there a way to print just specific controls, instead of the entire form?

    thanks

    J

  2. #2
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    106,729

    Re: Printing the contents of a specific control

    You handle the PrintPage event of a PrintDocument and then use GDI+ to print whatever you want. It's completely up to you. If you want to print text then you call DrawString. If you want to print a line then you call DrawLine. Etc. It's completely up to you what you draw and how you draw it, so you need to get whatever information and data you want from that control and draw it appropriately.

    If you want to get a better understanding of how WinForms printing works, visit the VB.NET CodeBank forum, sort by Thread Starter, page to threads started by Merrion and then check out his printing tutorial thread.

  3. #3

    Thread Starter
    New Member
    Join Date
    Mar 2021
    Posts
    10

    Re: Printing the contents of a specific control

    thanks for the reply..

    Could I have one form with 2 buttons, each button prints different parts of the same form?..thanks for your help

  4. #4
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    106,729

    Re: Printing the contents of a specific control

    Of course. Did you read what I said? You can print whatever you want. You can simply set a Boolean field in the Click event handler of each Button and then decide what to print in the PrintPage event handler based on that.

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