winforms - What does Controls.Add() do in c#? -


what code in c# winforms, can give me detailed explanation on how works? controls in statement.

controls.add(btn);  

controls instance of control.controlcollection class, represents collection of control objects, inheritance hierarchy

system.windows.forms.control.controlcollection

note:

the add, remove, , removeat methods enable add , remove individual controls collection. can use addrange or clear methods add or remove controls collection.

you can determine if control member of collection passing control contains method. index value of location of control in collection, pass control indexof method. collection can copied array calling copyto method.

example of removing control collection using 1 of it's method.

// remove radiobutton control if exists.  private void removebutton_click(object sender, system.eventargs e) {    if(panel1.controls.contains(removebutton))    {       panel1.controls.remove(removebutton);    } } 

refer control.controlcollection class


Comments

Popular posts from this blog

java - Andrioid studio start fail: Fatal error initializing 'null' -

android - Gradle sync Error:Configuration with name 'default' not found -

StringGrid issue in Delphi XE8 firemonkey mobile app -