Stacked controls in VB. NET forms

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.