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


C# TextBox.ResetBackColor方法代码示例

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


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

示例1: ReadOnly_BackColor_Set

		public void ReadOnly_BackColor_Set ()
		{
			textBox.BackColor = Color.Blue;
			textBox.ReadOnly = true;
			Assert.IsTrue (textBox.ReadOnly, "#A1");
			Assert.AreEqual (Color.Blue, textBox.BackColor, "#A2");

			Form form = new Form ();
			form.ShowInTaskbar = false;
			form.Controls.Add (textBox);
			form.Show ();

			Assert.IsTrue (textBox.ReadOnly, "#B1");
			Assert.AreEqual (Color.Blue, textBox.BackColor, "#B2");

			textBox.ReadOnly = false;
			Assert.IsFalse (textBox.ReadOnly, "#C1");
			Assert.AreEqual (Color.Blue, textBox.BackColor, "#C2");

			textBox.ReadOnly = true;
			Assert.IsTrue (textBox.ReadOnly, "#D1");
			Assert.AreEqual (Color.Blue, textBox.BackColor, "#D2");

			textBox.BackColor = Color.Red;
			Assert.IsTrue (textBox.ReadOnly, "#E1");
			Assert.AreEqual (Color.Red, textBox.BackColor, "#E2");

			textBox.ReadOnly = false;
			Assert.IsFalse (textBox.ReadOnly, "#F1");
			Assert.AreEqual (Color.Red, textBox.BackColor, "#F2");

			textBox.ReadOnly = true;
			textBox.ResetBackColor ();
			Assert.IsTrue (textBox.ReadOnly, "#G1");
			Assert.AreEqual (SystemColors.Control, textBox.BackColor, "#G2");

			form.Dispose ();

			textBox = new TextBox ();
			textBox.ReadOnly = true;
			textBox.BackColor = Color.Blue;
			Assert.IsTrue (textBox.ReadOnly, "#H1");
			Assert.AreEqual (Color.Blue, textBox.BackColor, "#H2");

			form = new Form ();
			form.ShowInTaskbar = false;
			form.Controls.Add (textBox);
			form.Show ();

			Assert.IsTrue (textBox.ReadOnly, "#I1");
			Assert.AreEqual (Color.Blue, textBox.BackColor, "#I2");

			textBox.ReadOnly = false;
			Assert.IsFalse (textBox.ReadOnly, "#J1");
			Assert.AreEqual (Color.Blue, textBox.BackColor, "#J2");

			textBox.ResetBackColor ();
			Assert.IsFalse (textBox.ReadOnly, "#K1");
			Assert.AreEqual (SystemColors.Window, textBox.BackColor, "#K2");
			
			form.Close ();
		}
开发者ID:Profit0004,项目名称:mono,代码行数:62,代码来源:TextBoxTest.cs


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