How can I draw on Panel so it does not blink?

后端 未结 2 1883
执笔经年
执笔经年 2021-01-21 02:59

This is my code. When I move cursor over Form it works, circle is moving but it is blinking. How can I fix this?

public partial class Preprocesor : Form
{
    in         


        
2条回答
  •  粉色の甜心
    2021-01-21 03:20

    You need to draw on a double-buffered control.

    Make a class that inherits Control and sets DoubleBuffered = true; in the constructor (this is a protected property).
    Use that control instead of your panel it there won't be any flickering.

    Also, you should not store a Graphics object for later.
    Instead, you should draw on e.Graphics in the Paint handler.

提交回复
热议问题