출처 : http://stackoverflow.com/questions/3419159/how-to-get-all-child-controls-of-a-windows-forms-form-of-a-specific-type-button#3426721



함수

public IEnumerable<Control> GetAll(Control control, Type type)

{

    var controls = control.Controls.Cast<Control>();

 

    return controls.SelectMany(ctrl => GetAll(ctrl, type))

                                .Concat(controls)

                                .Where(c => c.GetType() == type);

}

 

사용법

GetAll(this, typeof(Label))





Posted by motolies
,