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. Drawlines on different levels

Drawlines on different levels

Scheduled Pinned Locked Moved C#
graphicshelpdesigndata-structurestutorial
11 Posts 4 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.
  • A Offline
    A Offline
    AlexB47
    wrote on last edited by
    #1

    Hi, sorry for my bud English. I have to draw up an Forms.panel using a "Graphics" object (objPanel.CreateGraphics). I uploaded my design (graphic DrawLine) and I would "fizzle" because I run this graph by drawing a vertical line near the mouse pointer. Mine is a refresh problem because scrolling the mouse leave the previous vertical lines. I tried with "invalidate (rect)" but I do not redraw the chart below. Can you help me with an example? Is 'possible "to fizz" below the others drawlines and draw on a higher level without losing low level?

    Alex

    L D P 3 Replies Last reply
    0
    • A AlexB47

      Hi, sorry for my bud English. I have to draw up an Forms.panel using a "Graphics" object (objPanel.CreateGraphics). I uploaded my design (graphic DrawLine) and I would "fizzle" because I run this graph by drawing a vertical line near the mouse pointer. Mine is a refresh problem because scrolling the mouse leave the previous vertical lines. I tried with "invalidate (rect)" but I do not redraw the chart below. Can you help me with an example? Is 'possible "to fizz" below the others drawlines and draw on a higher level without losing low level?

      Alex

      L Offline
      L Offline
      Luc Pattyn
      wrote on last edited by
      #2

      I think this[^] should help you. :)

      Luc Pattyn [Forum Guidelines] [My Articles] [My CP bug tracking] Nil Volentibus Arduum

      Season's Greetings to all CPians.

      A 2 Replies Last reply
      0
      • A AlexB47

        Hi, sorry for my bud English. I have to draw up an Forms.panel using a "Graphics" object (objPanel.CreateGraphics). I uploaded my design (graphic DrawLine) and I would "fizzle" because I run this graph by drawing a vertical line near the mouse pointer. Mine is a refresh problem because scrolling the mouse leave the previous vertical lines. I tried with "invalidate (rect)" but I do not redraw the chart below. Can you help me with an example? Is 'possible "to fizz" below the others drawlines and draw on a higher level without losing low level?

        Alex

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

        Your problem is probably caused by not doing all of your drawing in the Panel's Paint event. Do NOT create your own graphics object. Use the one that Windows hands you in the event args of the Paint event.

        A guide to posting questions on CodeProject[^]
        Dave Kreskowiak

        A 1 Reply Last reply
        0
        • A AlexB47

          Hi, sorry for my bud English. I have to draw up an Forms.panel using a "Graphics" object (objPanel.CreateGraphics). I uploaded my design (graphic DrawLine) and I would "fizzle" because I run this graph by drawing a vertical line near the mouse pointer. Mine is a refresh problem because scrolling the mouse leave the previous vertical lines. I tried with "invalidate (rect)" but I do not redraw the chart below. Can you help me with an example? Is 'possible "to fizz" below the others drawlines and draw on a higher level without losing low level?

          Alex

          P Offline
          P Offline
          Paladin2000
          wrote on last edited by
          #4

          Drawing a grid on a panel? I just did that a little while ago. Here's a sample that makes a 20-px grid.

          private Pen pen = new Pen(Color.FromArgb(60, 60, 60), 1);

          private void something_Paint(object sender, PaintEventArgs e)
          {
          for (int x = 20; x < Width; x += 20) e.Graphics.DrawLine(pen, x, 0, x, Height);
          for (int y = 20; y < Height; y += 20) e.Graphics.DrawLine(pen, 0, y, Width, y);
          }

          [Edit]: Moved Pen object out of method.

          D 1 Reply Last reply
          0
          • P Paladin2000

            Drawing a grid on a panel? I just did that a little while ago. Here's a sample that makes a 20-px grid.

            private Pen pen = new Pen(Color.FromArgb(60, 60, 60), 1);

            private void something_Paint(object sender, PaintEventArgs e)
            {
            for (int x = 20; x < Width; x += 20) e.Graphics.DrawLine(pen, x, 0, x, Height);
            for (int y = 20; y < Height; y += 20) e.Graphics.DrawLine(pen, 0, y, Width, y);
            }

            [Edit]: Moved Pen object out of method.

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

            You forgot to Dispose the Pen. Nothing like an example that leaks GDI resources!

            A guide to posting questions on CodeProject[^]
            Dave Kreskowiak

            P 1 Reply Last reply
            0
            • D Dave Kreskowiak

              You forgot to Dispose the Pen. Nothing like an example that leaks GDI resources!

              A guide to posting questions on CodeProject[^]
              Dave Kreskowiak

              P Offline
              P Offline
              Paladin2000
              wrote on last edited by
              #6

              Or even better, don't re-create it on every Paint in the first place.  Moved it out of the method. :-D

              A 1 Reply Last reply
              0
              • L Luc Pattyn

                I think this[^] should help you. :)

                Luc Pattyn [Forum Guidelines] [My Articles] [My CP bug tracking] Nil Volentibus Arduum

                Season's Greetings to all CPians.

                A Offline
                A Offline
                AlexB47
                wrote on last edited by
                #7

                thanks ... I try this ..

                Alex

                1 Reply Last reply
                0
                • D Dave Kreskowiak

                  Your problem is probably caused by not doing all of your drawing in the Panel's Paint event. Do NOT create your own graphics object. Use the one that Windows hands you in the event args of the Paint event.

                  A guide to posting questions on CodeProject[^]
                  Dave Kreskowiak

                  A Offline
                  A Offline
                  AlexB47
                  wrote on last edited by
                  #8

                  thanks Dave, I try to not create a graphics obj ...

                  Alex

                  1 Reply Last reply
                  0
                  • P Paladin2000

                    Or even better, don't re-create it on every Paint in the first place.  Moved it out of the method. :-D

                    A Offline
                    A Offline
                    AlexB47
                    wrote on last edited by
                    #9

                    thanks to all .. ;)

                    Alex

                    1 Reply Last reply
                    0
                    • L Luc Pattyn

                      I think this[^] should help you. :)

                      Luc Pattyn [Forum Guidelines] [My Articles] [My CP bug tracking] Nil Volentibus Arduum

                      Season's Greetings to all CPians.

                      A Offline
                      A Offline
                      AlexB47
                      wrote on last edited by
                      #10

                      It works great!! Thanks a lot!! :))))))

                      Alex

                      L 1 Reply Last reply
                      0
                      • A AlexB47

                        It works great!! Thanks a lot!! :))))))

                        Alex

                        L Offline
                        L Offline
                        Luc Pattyn
                        wrote on last edited by
                        #11

                        You're welcome. :)

                        Luc Pattyn [Forum Guidelines] [My Articles] [My CP bug tracking] Nil Volentibus Arduum

                        Season's Greetings to all CPians.

                        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