Whenever I call the Dispose method on a Windows Forms form (obtained from System.Windows.Forms.Form) to close it, the Dispose method ends up freeing up resources and deleting the form.
I have runtime objects such as text fields, as shown below:
Textbox Tb = new Textbox();
The user can create new text fields dynamically. I want the text fields containing the data to remain around, and those that are empty are deleted. When I call the Dispose method on empty text fields, at runtime it looks as if they are located, but usually they are simply invisible.
So:
What is the difference between calling the dispose method in text blocks and classes derived from forms?
Why is the form located during the call, for example, Form1.Dispose(); and why not text fields at runtime as shown below?
if (tb.text=="") tb.Dispose();
source share