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

GetNextControl() public method

public GetNextControl ( Control ctl, bool forward ) : Control
ctl Control
forward bool
return Control
		public Control GetNextControl(Control ctl, bool forward) {

			if (!this.Contains(ctl)) {
				ctl = this;
			}

			if (forward) {
				ctl = FindControlForward(this, ctl);
			}
			else {
				ctl = FindControlBackward(this, ctl);
			}

			if (ctl != this) {
				return ctl;
			}
			return null;
		}

Usage Example

Example #1
0
		void WalkControls(Control container, Control start, int count, bool forward) {
			Control ctl;

			Console.WriteLine("Walking inside {0},\n starting at control {1}", container.Text, start != null ? start.Text : "null");

			ctl = start;
			for (int i = 0; i < count; i++) {
				ctl = container.GetNextControl(ctl, forward);
				if (ctl != null) {
					Console.WriteLine("{1} GetNextControl returned {0}, Tabindex: {2}", ctl.Text, i+1, ctl.TabIndex);
				} else {
					Console.WriteLine("{0} GetNextControl returned NULL", i+1);
				}
			}
		}
All Usage Examples Of System.Windows.Forms.Control::GetNextControl
Control