private void TopLevelForm_Load(object sender, EventArgs e) { Form f = sender as Form; Debug.Assert(f != null, "We should never wire up to anything that's not a form."); TabOrderManager tom = new TabOrderManager(f); // Add an override for everything with a tab scheme set EXCEPT for the form, which // serves as the root of the whole process. TabOrderManager.TabScheme formScheme = TabOrderManager.TabScheme.None; IDictionaryEnumerator extendeeEnumerator = extendees.GetEnumerator(); while (extendeeEnumerator.MoveNext()) { Control c = (Control)extendeeEnumerator.Key; TabOrderManager.TabScheme scheme = (TabOrderManager.TabScheme)extendeeEnumerator.Value; if (c == f) { formScheme = scheme; } else { tom.SetSchemeForControl(c, scheme); } } tom.SetTabOrder(formScheme); }
public void reArrangeTabOrder(Control form, int mode = 0) { TabOrderManager.TabScheme scheme; if (mode == 0) { scheme = TabOrderManager.TabScheme.DownFirst; } else { scheme = TabOrderManager.TabScheme.AcrossFirst; } TabOrderManager tom = new TabOrderManager(form); tom.SetTabOrder(scheme); }