Why is Visual Studio adding this code to the Class.Designer.cs class. Can someone tell me when this component variable gets any value? What picture should follow here?
private System.ComponentModel.IContainer components = null; /// <summary> /// Clean up any resources being used. /// </summary> /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> protected override void Dispose(bool disposing) { if(disposing && (components != null)) { components.Dispose(); } base.Dispose(disposing); }
A private field is componentsused to track one-time components in your form. Try dragging the component Timer, and you should see something like this in the code generated by the constructor:
components
Timer
this.components = new System.ComponentModel.Container(); this.timer1 = new System.Windows.Forms.Timer(this.components);
, Dispose(bool), disposable pattern. , , , Dispose , Dispose ( ).
Dispose(bool)
Dispose
, (common7\ide\itemtemplates\csharp\windows forms\1033\form.zip\form.designer.cs). , InitializeComponent(), , "this.components" . , - . , .
, , , Dispose() Designer.cs. form.cs, Dispose() , . , . , " ".
, Dispose() , , . , . Form , Controls.
components assigned when adding non-visual components, which must also be removed in a deterministic way (see the IDisposable template for more information).
Not all components use it, for example, HelpProvider and EventLog. You can even comment on this in these cases. Looks like I like ms bodge.