The System.Windows.Forms.Control.Dispose method is used to release all resources used by the Control object. This method is called automatically by the Garbage Collector, but it can also be called explicitly when the control is no longer needed or when you want to free up resources immediately.
Here are some examples of how to use the Dispose method:
Example #1:
//Create a new button control Button myButton = new Button();
//Add the button to a form this.Controls.Add(myButton);
//Dispose of the button when it is no longer needed myButton.Dispose();
Example #2:
//Create a new timer control Timer myTimer = new Timer();
//Start the timer myTimer.Start();
//Dispose of the timer when it is no longer needed myTimer.Dispose();
Both of these examples show how the Dispose method can be used to free up resources used by controls in a Windows Forms application.
The System.Windows.Forms.Control.Dispose method is part of the System.Windows.Forms namespace, which is part of the .NET Framework Class Library.
C# (CSharp) System.Windows.Forms Control.Dispose - 44 examples found. These are the top rated real world C# (CSharp) examples of System.Windows.Forms.Control.Dispose extracted from open source projects. You can rate examples to help us improve the quality of examples.