All pastes #23640 Raw Edit

Stuff

public text v1 · immutable
#23640 ·published 2005-09-22 20:41 UTC
rendered paste body
using System;
using System.Collections;
using System.Drawing;
using System.Windows.Forms;

namespace TestApp {
	class SearchBar : UserControl {
		TextBox		filterTextBox;
		ArrayList	results;

		public SearchBar() {
			results = new ArrayList();

			this.filterTextBox = new TextBox();
			this.filterTextBox.TabIndex = 1;
			this.filterTextBox.Dock = DockStyle.Fill;
			this.filterTextBox.HandleCreated += new EventHandler(filterTextBox_HandleCreated);
			this.Controls.Add(this.filterTextBox);
		}

		protected override void OnHandleCreated(EventArgs e) {
			results.Add("OnHandleCreated");
			base.OnHandleCreated(e);
		}

		public ArrayList Results {
			get {
				return results;
			}
		}

		private void filterTextBox_HandleCreated(object sender, EventArgs e) {
			results.Add("HandleCreatedEvent");
		}
	}

	class MainWindow : System.Windows.Forms.Form {
		public MainWindow() {
			SearchBar b = new SearchBar ();
			ClientSize = new System.Drawing.Size (250, 250);
			b.Dock = DockStyle.Fill;
			this.Controls.Add(b);
			this.CreateControl();

			string[] CreateEventsWant = {
				"OnHandleCreated",
				"HandleCreatedEvent"
			};

			VerifyEvents(b.Results, CreateEventsWant);
		}

		public bool VerifyEvents(ArrayList got, string[] want) {
			if (got.Count != want.Length) {
				return false;
			}

			for (int i = 0; i < got.Count; i++) {
				if (!((string)got[i]).Equals(want[i])) {
					return false;
				}
			}
			return true;
		}

		public static void Main(string[] args) {
			Application.Run(new MainWindow());
		}
	}
}