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


C# DateTimePicker.CreateControl方法代码示例

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


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

示例1: TextTest

		public void TextTest ()
		{
			CheckCulture ();

			DateTimePicker dt = new DateTimePicker ();
			EventLogger log = new EventLogger (dt);
			DateTime tomorrow = DateTime.Today.AddDays (1);

			log.Clear ();
			dt.Value = tomorrow;
			Assert.AreEqual ("", dt.Text, "#1");
			Assert.IsTrue (log.ContainsEventsOrdered ("ValueChanged"), "#1.1");

			log.Clear ();
			dt.CreateControl ();
			Assert.AreEqual (tomorrow.ToLongDateString (), dt.Text, "#2");
			Assert.IsTrue (log.ContainsEventsOrdered ("HandleCreated"), "#2.1");

			log.Clear ();
			dt.Text = "";
			Assert.AreEqual (DateTime.Today.ToLongDateString (), dt.Text, "#3");
			Assert.IsTrue (log.ContainsEventsOrdered ("ValueChanged", "TextChanged"), "#3.1");
			
			log.Clear ();
			dt.Text = null;
			Assert.AreEqual (DateTime.Today.ToLongDateString (), dt.Text, "#4");
			Assert.IsTrue (log.ContainsEventsOrdered ("ValueChanged", "TextChanged"), "#4.1, expected ValueChanged+TextChanged, got: " + log.EventsJoined ());

			log.Clear (); 
			dt.CustomFormat = "yyyy-MM-dd HH-mm";
			dt.Format = DateTimePickerFormat.Custom;
			Assert.AreEqual (DateTime.Now.ToString (dt.CustomFormat), dt.Text, "#5");
			Assert.IsTrue (log.ContainsEventsOrdered ("HandleDestroyed", "HandleCreated", "FormatChanged"), "#5.1");

			log.Clear ();
			dt.CustomFormat = "yyyy-MM-dd";
			Assert.AreEqual (DateTime.Now.ToString (dt.CustomFormat), dt.Text, "#6");
			Assert.AreEqual ("", log.EventsJoined (), "#6.1");
			
			log.Clear ();
			dt.Format = DateTimePickerFormat.Short;
			Assert.AreEqual (DateTime.Now.ToShortDateString (), dt.Text, "#7");
			Assert.IsTrue (log.ContainsEventsOrdered ("HandleDestroyed", "HandleCreated", "FormatChanged"), "#7.1");

			dt.Value = DateTime.Today;
			log.Clear ();
			dt.Value = DateTime.Today;
			Assert.AreEqual (0, log.EventsRaised, "#8");

			dt.Text = null;
			log.Clear ();
			dt.Text = null;
			Assert.IsTrue (log.ContainsEventsOrdered ("ValueChanged", "TextChanged"), "#9, expected ValueChanged+TextChanged, got: " + log.EventsJoined ());
			
			dt.Text = "";
			log.Clear ();
			dt.Text = "";
			Assert.IsTrue (log.ContainsEventsOrdered ("ValueChanged", "TextChanged"), "#19, expected ValueChanged+TextChanged, got: " + log.EventsJoined ());
		}
开发者ID:ItsVeryWindy,项目名称:mono,代码行数:59,代码来源:DateTimePickerTest.cs


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