您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

遍历文本框

遍历文本框

若要递归获取所有指定类型的控件和子控件,请使用以下扩展方法

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);
}

用法

var allText@R_35_2419@es = this.GetChildControls<Text@R_35_2419@>();
foreach (Text@R_35_2419@ tb in allText@R_35_2419@es)
{
    tb.Text = ...;
}
其他 2022/1/1 18:15:02 有593人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶