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
  1. Home
  2. General Programming
  3. Visual Basic
  4. how to keep the drawing on picturebox when new drawing is added?VB.Net

how to keep the drawing on picturebox when new drawing is added?VB.Net

Scheduled Pinned Locked Moved Visual Basic
helpcsharpgraphicstutorial
4 Posts 3 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.
  • M Offline
    M Offline
    MJay
    wrote on last edited by
    #1

    i have form1 and form2, form1 has a picturebox which i already drew something on it(e.g. rectangle) i active form2 to chose another shape to add below the rect, after form2 closed, the new shape should be added below the rect and the rect should be remained in its original position on the picbox(something like drawing flowchart).i used picbox_Paint event handler to draw the rect, but when i added new shape using the same Paint handler the rect is gone??!is there anyway to fix this problem?? what i try to find is the way to keep the drawing on the picbox remained till the application is closed... below is my current coding summary private sub picbox_paint(e....) .... handles paint if drawmode = 1 then e.graphic.drawrect() 'this is the first drawing picbox.invalide() 'refresh picbox end if if drawmode = 2 then 'this means user chose another shape from form2 e.graphic.drawXX() 'this is second drawing picbox.invalide() 'refresh picbox end if end sub

    D S 2 Replies Last reply
    0
    • M MJay

      i have form1 and form2, form1 has a picturebox which i already drew something on it(e.g. rectangle) i active form2 to chose another shape to add below the rect, after form2 closed, the new shape should be added below the rect and the rect should be remained in its original position on the picbox(something like drawing flowchart).i used picbox_Paint event handler to draw the rect, but when i added new shape using the same Paint handler the rect is gone??!is there anyway to fix this problem?? what i try to find is the way to keep the drawing on the picbox remained till the application is closed... below is my current coding summary private sub picbox_paint(e....) .... handles paint if drawmode = 1 then e.graphic.drawrect() 'this is the first drawing picbox.invalide() 'refresh picbox end if if drawmode = 2 then 'this means user chose another shape from form2 e.graphic.drawXX() 'this is second drawing picbox.invalide() 'refresh picbox end if end sub

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      You have to rewrite your paint handler to paint BOTH rectangles. WHat your doing in your handler is telling the PicBox to invalidate it's entire client area. THen your handling the paint event yourself, but never redrawing the first rectangle. You have to modify your code to keep track of EVERYTHING that you want repainted in the picbox, then redraw it all yourself since your handling the paint event yourself. RageInTheMachine9532

      1 Reply Last reply
      0
      • M MJay

        i have form1 and form2, form1 has a picturebox which i already drew something on it(e.g. rectangle) i active form2 to chose another shape to add below the rect, after form2 closed, the new shape should be added below the rect and the rect should be remained in its original position on the picbox(something like drawing flowchart).i used picbox_Paint event handler to draw the rect, but when i added new shape using the same Paint handler the rect is gone??!is there anyway to fix this problem?? what i try to find is the way to keep the drawing on the picbox remained till the application is closed... below is my current coding summary private sub picbox_paint(e....) .... handles paint if drawmode = 1 then e.graphic.drawrect() 'this is the first drawing picbox.invalide() 'refresh picbox end if if drawmode = 2 then 'this means user chose another shape from form2 e.graphic.drawXX() 'this is second drawing picbox.invalide() 'refresh picbox end if end sub

        S Offline
        S Offline
        steff kamush
        wrote on last edited by
        #3

        :rose::rose: Guess RageInTheMachine9532 is saying this so u retain both images: private sub picbox_paint(e....) .... handles paint if drawmode = 1 then e.graphic.drawrect() 'this is the first drawing picbox.invalide() 'refresh picbox end if if drawmode = 2 then 'this means user chose another shape from form2 e.graphic.drawrect() 'this is the first drawing e.graphic.drawXX() 'this is second drawing picbox.invalide() 'refresh picbox end if end sub

        M 1 Reply Last reply
        0
        • S steff kamush

          :rose::rose: Guess RageInTheMachine9532 is saying this so u retain both images: private sub picbox_paint(e....) .... handles paint if drawmode = 1 then e.graphic.drawrect() 'this is the first drawing picbox.invalide() 'refresh picbox end if if drawmode = 2 then 'this means user chose another shape from form2 e.graphic.drawrect() 'this is the first drawing e.graphic.drawXX() 'this is second drawing picbox.invalide() 'refresh picbox end if end sub

          M Offline
          M Offline
          MJay
          wrote on last edited by
          #4

          thanks for RageInTheMachine9532 and kamush help!! but wat i actually drawing is a flowchart, which mean each time user define a new drawmode or shape, the coding is very long and complicated and the label of the drawing will be different...if i change the code to wat u suggested me, my coding will be tremedous long and complicated!! i dunno whether u understand me or not(my english is pretty poor)... anyway thanks for ur help...i post a new question about this problem, if u have new idea plz reply there ok? thanks very much!!

          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