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

前端 未结 3 1812
后悔当初
后悔当初 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:00

    You should be disposing any controls within your custom control that implement the IDisposable interface. Ensure that your custom control implements this interface as well (add an implementation of the Dispose() method) so that you dispose of the controls within it properly (calling their Dispose() methods).

提交回复
热议问题