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


C# ListBox.CreateControl方法代码示例

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


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

示例1: HeightAndIntegralHeight

		public void HeightAndIntegralHeight ()
		{
			ListBox a = new ListBox();
			Size defaultSize = new Size(120, 96);
			Assert.AreEqual (defaultSize, a.Size, "A1");
			a.CreateControl();
			Assert.AreEqual (0, (a.ClientSize.Height % a.ItemHeight), "A2");
			a.IntegralHeight = false;
			Assert.AreEqual (a.Size, defaultSize, "A3");
			a.IntegralHeight = true;
			Assert.AreEqual (0, (a.ClientSize.Height % a.ItemHeight), "A4");

			Size clientSizeI = new Size(200, a.ItemHeight * 5);
			Size clientSize = clientSizeI + new Size(0, a.ItemHeight / 2);
			Size borderSize = new Size(a.Width - a.ClientSize.Width, a.Height - a.ClientSize.Height);
			Size totalSizeI = clientSizeI + borderSize;
			Size totalSize = clientSize + borderSize;

			a = new ListBox();
			a.ClientSize = clientSize;
			Assert.AreEqual (clientSize, a.ClientSize, "A5");
			Assert.AreEqual (totalSize, a.Size, "A6");
			a.IntegralHeight = false;
			a.IntegralHeight = true;
			Assert.AreEqual (clientSize, a.ClientSize, "A7");
			a.CreateControl();
			Assert.AreEqual (clientSizeI, a.ClientSize, "A8");
			Assert.AreEqual (totalSizeI, a.Size, "A9");
			a.IntegralHeight = false;
			Assert.AreEqual (clientSize, a.ClientSize, "A10");
			a.IntegralHeight = true;
			Assert.AreEqual (totalSizeI, a.Size, "A11");

			a = new ListBox();
			a.CreateControl();
			a.Size = totalSize;
			Assert.AreEqual (totalSizeI, a.Size, "A12");
			Assert.AreEqual (clientSizeI, a.ClientSize, "A13");
			a.IntegralHeight = false;
			Assert.AreEqual (totalSize, a.Size, "A14");
			Assert.AreEqual (clientSize, a.ClientSize, "A15");

			a = new ListBox();
			a.IntegralHeight = false;
			Assert.AreEqual (defaultSize, a.Size, "A16");
			a.CreateControl();
			Assert.AreEqual (defaultSize, a.Size, "A17");

			a = new ListBox();
			a.ClientSize = clientSize;
			a.IntegralHeight = false;
			Assert.AreEqual (clientSize, a.ClientSize, "A18");
			a.CreateControl();
			Assert.AreEqual (clientSize, a.ClientSize, "A19");
		}
开发者ID:nlhepler,项目名称:mono,代码行数:55,代码来源:ListBoxTest.cs


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