/// <summary>子Controlを検索し、結果を返す。</summary> /// <param name="cc">ControlCollection</param> /// <param name="id">Id of Control</param> /// <returns>子Control</returns> public static Control FindWebControl(ControlCollection cc, string id) { foreach (Control wc in cc) { if (wc.Controls.Count != 0) { // ノード if (wc.ID == id) { // ノード検索 return(wc); } else { // 再起検索 Control temp = null; temp = FxCmnFunction.FindWebControl(wc.Controls, id); if (temp != null) { // 発見 return(temp); } else { // 続行 } } } else { // リーフ if (wc.ID == id) { // リーフ検索 return(wc); } } } return(null); }
/// <summary>子Controlを検索し、結果をリストで返す。</summary> /// <param name="list">List(Control)</param> /// <param name="cc">ControlCollection</param> /// <param name="id">Id of Control</param> /// <returns>子ControlのList</returns> public static List <Control> FindWebControl(List <Control> list, ControlCollection cc, string id) { if (list == null) { list = new List <Control>(); } foreach (Control wc in cc) { if (wc.Controls.Count != 0) { // ノード if (wc.ID == id) { // ノード検索 list.Add(wc); } else { // 再起検索 list = FxCmnFunction.FindWebControl(list, wc.Controls, id); } } else { // リーフ if (wc.ID == id) { // リーフ検索 list.Add(wc); } } } return(list); }