public bool SelectNextControl(Control ctl, bool forward, bool tabStopOnly, bool nested, bool wrap) {
Control c;
#if DebugFocus
Console.WriteLine("{0}", this.FindForm());
printTree(this, "\t");
#endif
if (!this.Contains(ctl) || (!nested && (ctl.parent != this))) {
ctl = null;
}
c = ctl;
do {
c = GetNextControl(c, forward);
if (c == null) {
if (wrap) {
wrap = false;
continue;
}
break;
}
#if DebugFocus
Console.WriteLine("{0} {1}", c, c.CanSelect);
#endif
if (c.CanSelect && ((c.parent == this) || nested) && (c.tab_stop || !tabStopOnly)) {
c.Select (true, true);
return true;
}
} while (c != ctl); // If we wrap back to ourselves we stop
return false;
}