CopyPastor

Detecting plagiarism made easy.

Score: 1.7996435344422637; Reported for: String similarity, Exact paragraph match Open both answers

Possible Plagiarism

Plagiarized on 2017-03-04
by Muhammad Saqlain

Original Post

Original - Posted on 2011-02-01
by abatishchev



            
Present in both answers; Present only in the new answer; Present only in the old answer;

To get all controls
public static IEnumerable<TControl> GetChildControls<TControl>(this Control control) where TControl : Control { var children = (control.Controls != null) ? control.Controls.OfType<TControl>() : Enumerable.Empty<TControl>(); return children.SelectMany(c => GetChildControls<TControl>(c)).Concat(children); }
Now call this function
var allTextBoxes = this.GetChildControls<TextBox>(); foreach (TextBox tb in allTextBoxes) { if(tb.Text != ""){ //DO WHAT YOU WANT } }
To get all controls and sub-controls recursively of specified type, use this extension method:
public static IEnumerable<TControl> GetChildControls<TControl>(this Control control) where TControl : Control { var children = (control.Controls != null) ? control.Controls.OfType<TControl>() : Enumerable.Empty<TControl>(); return children.SelectMany(c => GetChildControls<TControl>(c)).Concat(children); }
usage:
var allTextBoxes = this.GetChildControls<TextBox>(); foreach (TextBox tb in allTextBoxes) { tb.Text = ...; }

        
Present in both answers; Present only in the new answer; Present only in the old answer;