當前位置: 首頁>>代碼示例>>C#>>正文


C# ScrollableControl.ScrollControlIntoView方法代碼示例

本文整理匯總了C#中System.Windows.Forms.ScrollableControl.ScrollControlIntoView方法的典型用法代碼示例。如果您正苦於以下問題:C# ScrollableControl.ScrollControlIntoView方法的具體用法?C# ScrollableControl.ScrollControlIntoView怎麽用?C# ScrollableControl.ScrollControlIntoView使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Windows.Forms.ScrollableControl的用法示例。


在下文中一共展示了ScrollableControl.ScrollControlIntoView方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: AutoScrollPositionTest

		public void AutoScrollPositionTest ()
		{
			ScrollableControl sc;

			sc = new ScrollableControl ();
			sc.AutoScroll = true;
			
			sc.AutoScrollPosition = new Point (-25, -50);
			Assert.AreEqual (Point.Empty, sc.AutoScrollPosition, "#01");

			sc.AutoScrollPosition = new Point (2500, 5000);
			Assert.AreEqual (Point.Empty, sc.AutoScrollPosition, "#02");
			
			sc.AutoScrollPosition = new Point (25, 50);
			Assert.AreEqual (Point.Empty, sc.AutoScrollPosition, "#03");
			
			object o = sc.Handle;

			sc.AutoScrollPosition = new Point (-25, -50);
			Assert.AreEqual (Point.Empty, sc.AutoScrollPosition, "#04");

			sc.AutoScrollPosition = new Point (2500, 5000);
			Assert.AreEqual (Point.Empty, sc.AutoScrollPosition, "#05");

			sc.AutoScrollPosition = new Point (25, 50);
			Assert.AreEqual (Point.Empty, sc.AutoScrollPosition, "#06");
			
			sc.Size = new Size (200, 400);
			sc.Location = new Point (20, 40);

			sc.AutoScrollPosition = new Point (-25, -50);
			Assert.AreEqual (Point.Empty, sc.AutoScrollPosition, "#07");

			sc.AutoScrollPosition = new Point (2500, 5000);
			Assert.AreEqual (Point.Empty, sc.AutoScrollPosition, "#08");

			sc.AutoScrollPosition = new Point (25, 50);
			Assert.AreEqual (Point.Empty, sc.AutoScrollPosition, "#09");
			
			
			Control c1, c2;
			c1 = new Control ();
			c1.Location = new Point (-100, -200);
			c1.Size = new Size (10, 10);
			sc.Controls.Add (c1);

			c2 = new Control ();
			c2.Location = new Point (400, 800);
			c2.Size = new Size (10, 10);
			sc.Controls.Add (c2);

			Assert.AreEqual (new Rectangle (0, 0, 410, 810), sc.DisplayRectangle, "#10");
			
			sc.ScrollControlIntoView (c2);

			Assert.AreEqual (new Point (-226, -426), sc.AutoScrollPosition, "#11");
			Assert.AreEqual (new Rectangle (-226, -426, 410, 810), sc.DisplayRectangle, "#12");
			Assert.AreEqual (new Point (-326, -626), c1.Location, "#13");
			Assert.AreEqual (new Point (174, 374), c2.Location, "#14");
			
			sc.AutoScrollPosition = new Point (-25, -50);
			Assert.AreEqual (Point.Empty, sc.AutoScrollPosition, "#01");
			Assert.AreEqual (new Rectangle (0, 0, 410, 810), sc.DisplayRectangle, "#15");
			Assert.AreEqual (new Point (-100, -200), c1.Location, "#16");
			Assert.AreEqual (new Point (400, 800), c2.Location, "#17");

			sc.AutoScrollPosition = new Point (2500, 5000);
			Assert.AreEqual (new Point (-226, -426), sc.AutoScrollPosition, "#18");
			Assert.AreEqual (new Rectangle (-226, -426, 410, 810), sc.DisplayRectangle, "#19");
			Assert.AreEqual (new Point (-326, -626), c1.Location, "#20");
			Assert.AreEqual (new Point (174, 374), c2.Location, "#21");

			sc.AutoScrollPosition = new Point (25, 50);
			Assert.AreEqual (new Point (-25, -50), sc.AutoScrollPosition, "#22");
			Assert.AreEqual (new Rectangle (-25, -50, 410, 810), sc.DisplayRectangle, "#23");
			Assert.AreEqual (new Point (-125, -250), c1.Location, "#24");
			Assert.AreEqual (new Point (375, 750), c2.Location, "#25");
			
			sc.ScrollControlIntoView (c1);


			Assert.AreEqual (Point.Empty, sc.AutoScrollPosition, "#26");
			Assert.AreEqual (new Rectangle (0, 0, 410, 810), sc.DisplayRectangle, "#27");
			Assert.AreEqual (new Point (-100, -200), c1.Location, "#28");
			Assert.AreEqual (new Point (400, 800), c2.Location, "#29");

			sc.AutoScrollPosition = new Point (2500, 5000);
			Assert.AreEqual (new Point (-226, -426), sc.AutoScrollPosition, "#30");
			Assert.AreEqual (new Rectangle (-226, -426, 410, 810), sc.DisplayRectangle, "#31");
			Assert.AreEqual (new Point (-326, -626), c1.Location, "#32");
			Assert.AreEqual (new Point (174, 374), c2.Location, "#33");

			sc.AutoScrollPosition = new Point (25, 50);
			Assert.AreEqual (new Point (-25, -50), sc.AutoScrollPosition, "#34");
			Assert.AreEqual (new Rectangle (-25, -50, 410, 810), sc.DisplayRectangle, "#35");
			Assert.AreEqual (new Point (-125, -250), c1.Location, "#36");
			Assert.AreEqual (new Point (375, 750), c2.Location, "#37");
			
			sc.ScrollControlIntoView (c2);

//.........這裏部分代碼省略.........
開發者ID:calumjiao,項目名稱:Mono-Class-Libraries,代碼行數:101,代碼來源:ScrollableControlTest.cs


注:本文中的System.Windows.Forms.ScrollableControl.ScrollControlIntoView方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。