Removing dynamically created controls

I have a TabControl WinForms that I dynamically add TabPages at runtime. Each tab contains a WebBrowser control. I also have the option to remove TabPages at runtime.

Should I worry about recycling () the TabPage and / or WebBrowser controls?

It seems to me that I should at least Dispose () manage the WebBrowser, as this is a bit of a hog resource.

+3
source share
3 answers

You must delete () your tab when you delete it. This will automatically remove all child controls.

. Control.Dispose:

, , , , .

"" .

+2

, , IDisposable, Dispose, . IDisposable.

+2

Dispose(), , . , , Dispose().

CodeProject, Dispose Dispose. http://www.codeproject.com/KB/cs/idisposable.aspx

+1
source

Source: https://habr.com/ru/post/1712239/


All Articles