System.Windows.Forms.Control.SelectNextControl C# (CSharp) Method

SelectNextControl() public method

public SelectNextControl ( Control ctl, bool forward, bool tabStopOnly, bool nested, bool wrap ) : bool
ctl Control
forward bool
tabStopOnly bool
nested bool
wrap bool
return bool
		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;
		}

Usage Example

Example #1
0
 //  CSS added for keyboard interop
 protected override bool ProcessDialogKey(Keys keyData)
 {
     _focusTarget.Enabled = false;
     try
     {
         if ((keyData & (Keys.Alt | Keys.Control)) == Keys.None)
         {
             Keys keyCode = (Keys)keyData & Keys.KeyCode;
             if (keyCode == Keys.Tab || keyCode == Keys.Left ||
                 keyCode == Keys.Right || keyCode == Keys.Up ||
                 keyCode == Keys.Down)
             {
                 if (this.Focused || this.ContainsFocus)
                 {
                     // CSS:  In WF apps, by default, arrow keys always wrap within a container
                     // However, we don't want them to wrap in the Adapter, which always has only
                     // one immediate child
                     if ((keyCode == Keys.Left || keyCode == Keys.Right || keyCode == Keys.Down || keyCode == Keys.Up) &&
                         (this.ActiveControl != null && this.ActiveControl.Parent == this))
                     {
                         SWF.Control c = this.ActiveControl.Parent;
                         return(c.SelectNextControl(this.ActiveControl, keyCode == Keys.Right || keyCode == Keys.Down, false, false, false));
                     }
                     else
                     {
                         return(base.ProcessDialogKey(keyData));
                     }
                 }
             }
         }
         return(false);
     }
     finally { _focusTarget.Enabled = true; }
 }
All Usage Examples Of System.Windows.Forms.Control::SelectNextControl
Control