Override
-
Can i do like this? Is this allowed in C#? protected override void OnPaint(PaintEventArgs e) { ... ... } private void GenerateChart() { ... OnPaint(PaintEventArgs e) ... }
-
Can i do like this? Is this allowed in C#? protected override void OnPaint(PaintEventArgs e) { ... ... } private void GenerateChart() { ... OnPaint(PaintEventArgs e) ... }
-
Can i do like this? Is this allowed in C#? protected override void OnPaint(PaintEventArgs e) { ... ... } private void GenerateChart() { ... OnPaint(PaintEventArgs e) ... }
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 )
-
Can i do like this? Is this allowed in C#? protected override void OnPaint(PaintEventArgs e) { ... ... } private void GenerateChart() { ... OnPaint(PaintEventArgs e) ... }
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.
-
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.
I try to do that but get error while compiling. Am i missing something?
-
Can i do like this? Is this allowed in C#? protected override void OnPaint(PaintEventArgs e) { ... ... } private void GenerateChart() { ... OnPaint(PaintEventArgs e) ... }
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(...);
withInvalidate();
and you're done.Regards, mav -- Black holes are the places where God divided by 0...