Refresh OnPaint on Windows Form - C#

Hi lately, I been scripting a C# component for creating a simple winform that draws a shape in this case a rectangle and let you change its dimensions by the inputs of the component.

So, I been trying to clear the OnPaint event, but I’m not sure if my script is the correct way,
There is some jittering or lagging whenever the dimensions of the rectangle change, so I was wondering if that behavior is natural? or What should be the correct way??? Thanks

Clear (8.3 KB)

You were subscribing to the Paint event every time you change a parameter, you only have to do it once.
To avoid flickering, in your case activating DoubleBuffered is solved, and for that you must do it by creating a class that inherits Form.
Clear (6.6 KB)

1 Like

Thanks Again, for all the help, I’m been trying to find some guides to do this on C# but I could only find examples for VB, do you know any learning material for events in C#???