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. C#
  4. Line in PictureBox

Line in PictureBox

Scheduled Pinned Locked Moved C#
questiongraphicshelp
3 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.
  • G Offline
    G Offline
    godspeed123
    wrote on last edited by
    #1

    Hi, I have used the picture box to draw an image on the screen. Its loading perfectly, now I want to draw over some parts of the image, with rectangles and lines. I tried to draw on the picture box by doing the following but nothing shows up? How can I go about doing this. Graphics g = pictureBox1.CreateGraphics(); SolidBrush solidBrush = new SolidBrush(Color.Blue); g.FillRectangle(solidBrush, 0, 0, 100, 100); Any help would be greatly appreciated

    N C 2 Replies Last reply
    0
    • G godspeed123

      Hi, I have used the picture box to draw an image on the screen. Its loading perfectly, now I want to draw over some parts of the image, with rectangles and lines. I tried to draw on the picture box by doing the following but nothing shows up? How can I go about doing this. Graphics g = pictureBox1.CreateGraphics(); SolidBrush solidBrush = new SolidBrush(Color.Blue); g.FillRectangle(solidBrush, 0, 0, 100, 100); Any help would be greatly appreciated

      N Offline
      N Offline
      netJP12L
      wrote on last edited by
      #2

      You cannot simply draw a line or rectangle on top the image. They are drawn behind the image. You need to make them a control and set the foreground or background property.

      1 Reply Last reply
      0
      • G godspeed123

        Hi, I have used the picture box to draw an image on the screen. Its loading perfectly, now I want to draw over some parts of the image, with rectangles and lines. I tried to draw on the picture box by doing the following but nothing shows up? How can I go about doing this. Graphics g = pictureBox1.CreateGraphics(); SolidBrush solidBrush = new SolidBrush(Color.Blue); g.FillRectangle(solidBrush, 0, 0, 100, 100); Any help would be greatly appreciated

        C Offline
        C Offline
        Christian Graus
        wrote on last edited by
        #3

        "Graphics g = pictureBox1.CreateGraphics();" That is a bad idea unless you're drawing something you want to erase, like a rubber band. Painting should take place in the paint event. And, at this point, you should just draw your bitmap in the paint event, then draw on it.

        Christian Graus Please read this if you don't understand the answer I've given you. If you're still stuck, ask me for more information.

        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