当前位置: 首页>>代码示例>>C#>>正文


C# ContainerControl.Select方法代码示例

本文整理汇总了C#中System.Windows.Forms.ContainerControl.Select方法的典型用法代码示例。如果您正苦于以下问题:C# ContainerControl.Select方法的具体用法?C# ContainerControl.Select怎么用?C# ContainerControl.Select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Forms.ContainerControl的用法示例。


在下文中一共展示了ContainerControl.Select方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: EnterLeaveFocusEventTest

		public void EnterLeaveFocusEventTest ()
		{
			if (TestHelper.RunningOnUnix) {
				Assert.Ignore ("Relies on form.Show() synchronously generating WM_ACTIVATE");
			}

			Form f = new Form();
			f.ShowInTaskbar = false;

			f.Name = "Form1";
			ContainerControl cc0 = new ContainerControl();
			cc0.Name = "ContainerControl 0";
			ContainerControl cc1 = new ContainerControl();
			cc1.Name = "ContainerControl 1";
			ContainerControl cc2 = new ContainerControl();
			cc2.Name = "ContainerControl 2";
			Control c1 = new Control();
			c1.Name = "Control 1";
			Control c2 = new Control();
			c2.Name = "Control 2";

			connect(f);
			connect(cc0);
			connect(cc1);
			connect(cc2);
			connect(c1);
			connect(c2);

			cc0.Controls.Add(cc1);
			cc0.Controls.Add(cc2);
			cc1.Controls.Add(c1);
			cc2.Controls.Add(c2);

			f.Controls.Add(cc0);

			sb = new StringBuilder ();
			f.Show ();
			c1.Select();

			Assert.AreEqual (@"OnEnter: ContainerControl 0 System.Windows.Forms.ContainerControl
OnEnter: ContainerControl 1 System.Windows.Forms.ContainerControl
OnEnter: Control 1 System.Windows.Forms.Control
OnGotFocus: Control 1 System.Windows.Forms.Control
",
					 sb.ToString (), "1");

			sb.Length = 0;
			c2.Select();
			Assert.AreEqual (@"OnLeave: Control 1 System.Windows.Forms.Control
OnLeave: ContainerControl 1 System.Windows.Forms.ContainerControl
OnValidating: Control 1 System.Windows.Forms.Control
OnValidated: Control 1 System.Windows.Forms.Control
OnValidating: ContainerControl 1 System.Windows.Forms.ContainerControl
OnValidated: ContainerControl 1 System.Windows.Forms.ContainerControl
OnEnter: ContainerControl 2 System.Windows.Forms.ContainerControl
OnEnter: Control 2 System.Windows.Forms.Control
OnLostFocus: Control 1 System.Windows.Forms.Control
OnGotFocus: Control 2 System.Windows.Forms.Control
",
					 sb.ToString (), "2");

			sb.Length = 0;
			cc1.Select();
			Assert.AreEqual (@"OnLeave: Control 2 System.Windows.Forms.Control
OnLeave: ContainerControl 2 System.Windows.Forms.ContainerControl
OnValidating: Control 2 System.Windows.Forms.Control
OnValidated: Control 2 System.Windows.Forms.Control
OnValidating: ContainerControl 2 System.Windows.Forms.ContainerControl
OnValidated: ContainerControl 2 System.Windows.Forms.ContainerControl
OnEnter: ContainerControl 1 System.Windows.Forms.ContainerControl
OnLostFocus: Control 2 System.Windows.Forms.Control
OnGotFocus: ContainerControl 1 System.Windows.Forms.ContainerControl
",
					 sb.ToString (), "3");

			sb.Length = 0;
			cc2.Select();
			Assert.AreEqual (@"OnLeave: ContainerControl 1 System.Windows.Forms.ContainerControl
OnValidating: ContainerControl 1 System.Windows.Forms.ContainerControl
OnValidated: ContainerControl 1 System.Windows.Forms.ContainerControl
OnEnter: ContainerControl 2 System.Windows.Forms.ContainerControl
OnLostFocus: ContainerControl 1 System.Windows.Forms.ContainerControl
OnGotFocus: ContainerControl 2 System.Windows.Forms.ContainerControl
",
					 sb.ToString (), "4");

			Assert.IsNull (cc2.ActiveControl, "5");

			sb.Length = 0;
			c2.Select();
			Assert.AreEqual (@"OnEnter: Control 2 System.Windows.Forms.Control
OnLostFocus: ContainerControl 2 System.Windows.Forms.ContainerControl
OnGotFocus: Control 2 System.Windows.Forms.Control
",
					 sb.ToString (), "6");

			sb.Length = 0;
			cc1.Select();
			Assert.AreEqual (@"OnLeave: Control 2 System.Windows.Forms.Control
OnLeave: ContainerControl 2 System.Windows.Forms.ContainerControl
//.........这里部分代码省略.........
开发者ID:nlhepler,项目名称:mono,代码行数:101,代码来源:FocusTest.cs


注:本文中的System.Windows.Forms.ContainerControl.Select方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。