c# - Loop through Groupbox in TabControl -
i have wpf contain tab control (page1, page2, , page3).
in tab control page 2, have 3 groupbox (groupbox_a, groupbox_b, , groupbox_c), , each of groupbox contain 3 textbox.
may know c# code loop through textbox , clear content.
this function return textboxes within tab control.
public static ienumerable<t> findvisualchildren<t>(dependencyobject depobj) t : dependencyobject { if (depobj != null) { (int = 0; < visualtreehelper.getchildrencount(depobj); i++) { dependencyobject child = visualtreehelper.getchild(depobj, i); if (child != null && child t) { yield return (t)child; } foreach (t childofchild in findvisualchildren<t>(child)) { yield return childofchild; } } } }
you can text boxes enumerating :
foreach (var textbox in findvisualchildren<textbox>(window)) { // tb here }
source : find controls in wpf window type
Comments
Post a Comment