C#: Is it necessary to dispose of a graphics element inside a custom control?

前端 未结 3 1817
后悔当初
后悔当初 2021-01-20 15:31

I\'ve created a custom control, overridden it\'s paint event. When I try to dispose of the graphics I create they just disappear from the screen. Don\'t I need to use dispos

3条回答
  •  一个人的身影
    2021-01-20 16:12

    Without an example it's hard to say exactly where the phoblem is, but I can guess:

    In your overriden OnPaint event, there's a parameter PaintEventArgs. You should perform all drawing onto this parameter's Graphics object, and you're good to go. That should make your graphics stick.

提交回复
热议问题