If you have ever encountered a job of modifying all controls at runtime, you will be able to understand how cumbersome it is to modify controls one by one. In fact, there is a simple method in VB. NET to implement this function.
Control Selection
The form contains a series of controls, which can be selected cyclically to change the properties of the control at runtime. For example, add two text boxes to the form and then add the following
Code: Private sub setcontrols () dim cControl as Controlfor each cControl InME. controlsif (typeof cControl is textbox) thenccontrol. TEXT = "ABC" End ifnext ccontrolend sub Figure A shows the interface that you will see after running the code. Figure A in this example, I define the variable cControl as a control object and create a for loop to check all the controls on the form. If the control is a text box, set the text attribute to "ABC", so that all text box values in the form will be set to "ABC ". You can set other properties of other types of controls in a similar way.