Get all control from from in C#

0 thích 0 không thích
1 lượt xem
đã hỏi 7 Tháng 4, 2023 trong Lập trình C# bởi nguyenthao (9,000 điểm)
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);
}
Looking for an answer?  Share this question:     

Xin vui lòng đăng nhập hoặc đăng ký để trả lời câu hỏi này.

...