Skip to main content

How to: Recursively iterate through the child panels of a specific panel

The following example demonstrates how to recursively iterate through the child panels of a specific panel. The IterateChildPanels method invokes the DoSomeOperation method for the last child of the specified panel (the child panel that doesn’t in turn contain any children).

using DevExpress.XtraBars.Docking;
// ...
void DoSomeOperation(DockPanel panel) {
   //...
}

void IterateChildPanels(DockPanel parentPanel) {
   if(parentPanel == null) return;
   for(int i = 0; i < parentPanel.Count; i++) {
      DockPanel childPanel = parentPanel[i];
      if(childPanel.Count == 0)
         DoSomeOperation(childPanel);
      else
         IterateChildPanels(childPanel);
   }
}