Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. Visual Basic
  4. print graphic [modified]

print graphic [modified]

Scheduled Pinned Locked Moved Visual Basic
graphicscomdata-structurestutorialquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    codeadair
    wrote on last edited by
    #1

    I write a program to print an undee chart.The main code as follows: Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click AddHandler PrintDocument1.PrintPage, AddressOf drawpictoprinter PrintDocument1.Print() End Sub Private Sub drawpictoprinter(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Dim pg As Graphics pg = e.Graphics pg.TranslateTransform(xtran, ytran) 'xtran,ytran >0 pg.ScaleTransform(xscaletran, yscaletran) Dim j As Integer Try For j = 0 To rwrecord - 1 'rwrecord is the unbound of 'array redraw or ydraw pg.DrawLine(redrawpen, xredraw(j), -yredraw(j), xredraw(j + 1), -yredraw(j + 1)) Next Catch ex As Exception Throw ex Finally pg = Nothing GC.Collect() End Try End Sub when i press button5 the first time.what do you think the output chart of printer?And the second time?The third time?.... When i do it the first time.Output chart is an undee chart that i want to be.But the second time when i do it.Two undee chart appear.and One is upper,the other is under it.The horizontal distance is xtran,The vertical distance is ytran. I do think the focus is pg.TranslateTransform(xtran, ytran) and pg.ScaleTransform(xscaletran, yscaletran) I run the program step by step.what i found are: 1>when i press button5 the first time.drawpictoprinter method execute one time 2>When i do it the second time.drawpictoprinter method execute two times 3> And so on WHY? Any care will be appreciated much Best regards ICQ:258-235-734 MSN:msnadair@hotmail.com -- modified at 9:19 Friday 2nd June, 2006

    R 1 Reply Last reply
    0
    • C codeadair

      I write a program to print an undee chart.The main code as follows: Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click AddHandler PrintDocument1.PrintPage, AddressOf drawpictoprinter PrintDocument1.Print() End Sub Private Sub drawpictoprinter(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Dim pg As Graphics pg = e.Graphics pg.TranslateTransform(xtran, ytran) 'xtran,ytran >0 pg.ScaleTransform(xscaletran, yscaletran) Dim j As Integer Try For j = 0 To rwrecord - 1 'rwrecord is the unbound of 'array redraw or ydraw pg.DrawLine(redrawpen, xredraw(j), -yredraw(j), xredraw(j + 1), -yredraw(j + 1)) Next Catch ex As Exception Throw ex Finally pg = Nothing GC.Collect() End Try End Sub when i press button5 the first time.what do you think the output chart of printer?And the second time?The third time?.... When i do it the first time.Output chart is an undee chart that i want to be.But the second time when i do it.Two undee chart appear.and One is upper,the other is under it.The horizontal distance is xtran,The vertical distance is ytran. I do think the focus is pg.TranslateTransform(xtran, ytran) and pg.ScaleTransform(xscaletran, yscaletran) I run the program step by step.what i found are: 1>when i press button5 the first time.drawpictoprinter method execute one time 2>When i do it the second time.drawpictoprinter method execute two times 3> And so on WHY? Any care will be appreciated much Best regards ICQ:258-235-734 MSN:msnadair@hotmail.com -- modified at 9:19 Friday 2nd June, 2006

      R Offline
      R Offline
      Robert Rohde
      wrote on last edited by
      #2

      codeadair wrote:

      AddHandler PrintDocument1.PrintPage, AddressOf drawpictoprinter

      This is causing it. You are adding the event handler everytime you press your button. Either unbind (RemoveHandler) it after you have finished or make sure you bind it only once.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups