當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。