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. how to refresh or keep the graphics

how to refresh or keep the graphics

Scheduled Pinned Locked Moved C#
graphicstutorialquestion
5 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.
  • D Offline
    D Offline
    donkaiser
    wrote on last edited by
    #1

    hello im using the graphics class to draw some stuff on a form. Graphics Draw = this.form1.CreateGraphics(); Draw.FillEllipse(Brushes.Red, Circles); something like that. But once the graphic is drawn and i move another form over, it disappears. so how can i keep my graphic display all the time. Thank you Donkaiser

    D A 2 Replies Last reply
    0
    • D donkaiser

      hello im using the graphics class to draw some stuff on a form. Graphics Draw = this.form1.CreateGraphics(); Draw.FillEllipse(Brushes.Red, Circles); something like that. But once the graphic is drawn and i move another form over, it disappears. so how can i keep my graphic display all the time. Thank you Donkaiser

      D Offline
      D Offline
      Dustin Metzgar
      wrote on last edited by
      #2

      You could create an image, get the graphics context off of the image, and draw it there. Then just keep that image up on the form.


      Logifusion[^]

      D 1 Reply Last reply
      0
      • D Dustin Metzgar

        You could create an image, get the graphics context off of the image, and draw it there. Then just keep that image up on the form.


        Logifusion[^]

        D Offline
        D Offline
        donkaiser
        wrote on last edited by
        #3

        do you have an example? I know the logic but im sure C# has some class that will take care that. and by image u mean a bitmap image or jpg image. Donkaiser

        D 1 Reply Last reply
        0
        • D donkaiser

          hello im using the graphics class to draw some stuff on a form. Graphics Draw = this.form1.CreateGraphics(); Draw.FillEllipse(Brushes.Red, Circles); something like that. But once the graphic is drawn and i move another form over, it disappears. so how can i keep my graphic display all the time. Thank you Donkaiser

          A Offline
          A Offline
          atuldeore
          wrote on last edited by
          #4

          The graphics drawn disappears because when you move the form, paint event occurs and it rpaints the form which eventually overwrites what you have written. To make the drawn graphics persistant try to override the Paint event of the form. Put your painting code in it. Hope this helps. Every bit counts ADD

          1 Reply Last reply
          0
          • D donkaiser

            do you have an example? I know the logic but im sure C# has some class that will take care that. and by image u mean a bitmap image or jpg image. Donkaiser

            D Offline
            D Offline
            Dustin Metzgar
            wrote on last edited by
            #5

            Absolutely. Take your form and add a PictureBox control to it. Then in your constructor you can do this:

            this.pictureBox1.Image = new Bitmap(this.pictureBox1.Width, this.pictureBox1.Height);
            Graphics g = Graphics.FromImage(this.pictureBox1.Image);
            g.FillEllipse(Brushes.Red, 5, 5, 50, 50);

            You don't have to set anything on PictureBox, just put it on the form.


            Logifusion[^]

            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