You can, but you should know that the graphics rendered in this event won't be permanently kept on this control; very first invalidation will overwrite the pixels you just rendered with the graphics rendered by overridden
, and, if
was called, the event handlers of the event
would also come into the game. This is how it works.
If you can take it into account in your logic, you could render something using the instance of
obtained from the window using the method
However, I would not advise you to do that, unless you understand very well what you are doing.
Alternatively, you could better do all the rendering in your
. This is the idea: you render all graphics from some data model, vector graphics data kept in memory. On click, you modify the data model according to click data, and then immediately invalidate all the scene or part of it using one of the these methods:
Internally, this is all based on processing of
window message, which is very cunning and highly optimized. For some background, please see my past answers:
What kind of playful method is Paint? (DataGridViewImageCell.Paint(...))
capture the drawing on a panel
Drawing Lines between mdi child forms
How to speed up my vb.net application?
Zoom image in C# .net mouse wheel