프로그램 자료/Visual C#
폼에 있는 모든 콘트롤 가져오기
motolies
2016. 7. 12. 10:15
함수
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))