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. Override

Override

Scheduled Pinned Locked Moved C#
6 Posts 5 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.
  • S Offline
    S Offline
    shamsteady
    wrote on last edited by
    #1

    Can i do like this? Is this allowed in C#? protected override void OnPaint(PaintEventArgs e) { ... ... } private void GenerateChart() { ... OnPaint(PaintEventArgs e) ... }

    G C P M 4 Replies Last reply
    0
    • S shamsteady

      Can i do like this? Is this allowed in C#? protected override void OnPaint(PaintEventArgs e) { ... ... } private void GenerateChart() { ... OnPaint(PaintEventArgs e) ... }

      G Offline
      G Offline
      Guffa
      wrote on last edited by
      #2

      Yes, but generally you shouldn't call the paint event directly, but invalidate the control or region that needs repainting and let the system call the paint event.

      --- single minded; short sighted; long gone;

      1 Reply Last reply
      0
      • S shamsteady

        Can i do like this? Is this allowed in C#? protected override void OnPaint(PaintEventArgs e) { ... ... } private void GenerateChart() { ... OnPaint(PaintEventArgs e) ... }

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

        No, you can't, because you can't generate the PaintEventArgs. Instead, call Invalidate(), which will force a paint event to be properly called.

        Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

        1 Reply Last reply
        0
        • S shamsteady

          Can i do like this? Is this allowed in C#? protected override void OnPaint(PaintEventArgs e) { ... ... } private void GenerateChart() { ... OnPaint(PaintEventArgs e) ... }

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

          Sure, go ahead, we learn more from getting things wrong than by getting them right the first time, or by asking and being given the answer.

          S 1 Reply Last reply
          0
          • P PIEBALDconsult

            Sure, go ahead, we learn more from getting things wrong than by getting them right the first time, or by asking and being given the answer.

            S Offline
            S Offline
            shamsteady
            wrote on last edited by
            #5

            I try to do that but get error while compiling. Am i missing something?

            1 Reply Last reply
            0
            • S shamsteady

              Can i do like this? Is this allowed in C#? protected override void OnPaint(PaintEventArgs e) { ... ... } private void GenerateChart() { ... OnPaint(PaintEventArgs e) ... }

              M Offline
              M Offline
              mav northwind
              wrote on last edited by
              #6

              This is not correct syntax. You'd have to write

              PaintEventArgs e = new PaintEventArgs();
              // set up e's properties
              // ...
              OnPaint(e);

              but like the others suggested, this is really not the correct way of doing things. Just replace the call to OnPaint(...); with Invalidate(); and you're done.

              Regards, mav -- Black holes are the places where God divided by 0...

              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