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


C# TextBox.MoveSelectedWord方法代碼示例

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


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

示例1: MoveSelectedWord_EmptyString

		public void MoveSelectedWord_EmptyString()
		{
			using (TextBox txt = new TextBox())
			{
				Assert.IsFalse(txt.MoveSelectedWord(true));
				Assert.AreEqual(String.Empty, txt.Text);
				Assert.IsFalse(txt.MoveSelectedWord(false));
				Assert.AreEqual(String.Empty, txt.Text);
			}
		}
開發者ID:bbriggs,項目名稱:FieldWorks,代碼行數:10,代碼來源:TextBoxExtensionsTests.cs

示例2: MoveSelectedWord_OneWord

		public void MoveSelectedWord_OneWord()
		{
			const string initial = "dog";
			using (TextBox txt = new TextBox())
			{
				txt.Text = initial;

				Assert.IsFalse(txt.MoveSelectedWord(true));
				Assert.AreEqual(initial, txt.Text);
				Assert.IsFalse(txt.MoveSelectedWord(false));
				Assert.AreEqual(initial, txt.Text);

				txt.SelectionStart = 3;
				Assert.IsFalse(txt.MoveSelectedWord(true));
				Assert.AreEqual(initial, txt.Text);
				Assert.IsFalse(txt.MoveSelectedWord(false));
				Assert.AreEqual(initial, txt.Text);

				txt.SelectionStart = 0;
				txt.SelectionLength = 3;
				Assert.IsFalse(txt.MoveSelectedWord(true));
				Assert.AreEqual(initial, txt.Text);
				Assert.IsFalse(txt.MoveSelectedWord(false));
				Assert.AreEqual(initial, txt.Text);
			}
		}
開發者ID:bbriggs,項目名稱:FieldWorks,代碼行數:26,代碼來源:TextBoxExtensionsTests.cs

示例3: MoveSelectedWord_AdvanceInitialPunc

		public void MoveSelectedWord_AdvanceInitialPunc()
		{
			//                      0         1         2         3         4
			//                      0123456789012345678901234567890123456789012
			const string initial = "\u00BFQue\u0301 le dijo Potifar a Jose\u0301?";
			using (TextBox txt = new TextBox())
			{
				txt.Text = initial;
				txt.SelectionStart = 0;
				txt.SelectionLength = 1;
				Assert.IsTrue(txt.MoveSelectedWord(true));
				//               0         1         2         3         4
				//               0123456789012345678901234567890123456789012
				Assert.AreEqual("Que\u0301 \u00BFle dijo Potifar a Jose\u0301?", txt.Text);
			}
		}
開發者ID:bbriggs,項目名稱:FieldWorks,代碼行數:16,代碼來源:TextBoxExtensionsTests.cs

示例4: MoveSelectedWord_AdvanceWordFollowingSentenceInitialPunc

		public void MoveSelectedWord_AdvanceWordFollowingSentenceInitialPunc()
		{
			//                      0         1         2         3         4
			//                      0123456789012345678901234567890123456789012
			const string initial = "\u00BFnoto\u0301 Que\u0301 Potifar Jose\u0301 Potifar familia?";
			using (TextBox txt = new TextBox())
			{
				txt.Text = initial;
				txt.SelectionStart = 1;
				txt.SelectionLength = 5;
				Assert.IsTrue(txt.MoveSelectedWord(true));
				Assert.AreEqual("\u00BFQue\u0301 noto\u0301 Potifar Jose\u0301 Potifar familia?", txt.Text);
			}
		}
開發者ID:bbriggs,項目名稱:FieldWorks,代碼行數:14,代碼來源:TextBoxExtensionsTests.cs

示例5: MoveSelectedWord_OneWord_MiddleOfWordSelected

		public void MoveSelectedWord_OneWord_MiddleOfWordSelected()
		{
			const string initial = "dog";
			using (TextBox txt = new TextBox())
			{

				txt.Text = initial;
				txt.SelectionStart = 1;
				txt.SelectionLength = 1;
				Assert.IsTrue(txt.MoveSelectedWord(true));
				Assert.AreEqual("dgo", txt.Text);
				Assert.AreEqual(2, txt.SelectionStart);
				Assert.AreEqual(1, txt.SelectionLength);

				txt.Text = initial;
				txt.SelectionStart = 1;
				txt.SelectionLength = 1;
				Assert.IsTrue(txt.MoveSelectedWord(false));
				Assert.AreEqual("odg", txt.Text);
				Assert.AreEqual(0, txt.SelectionStart);
				Assert.AreEqual(1, txt.SelectionLength);
			}
		}
開發者ID:bbriggs,項目名稱:FieldWorks,代碼行數:23,代碼來源:TextBoxExtensionsTests.cs

示例6: MoveSelectedWord_MoveSelectedWordBackwardPastComma

		public void MoveSelectedWord_MoveSelectedWordBackwardPastComma()
		{
			//                      0         1         2         3         4
			//                      0123456789012345678901234567890123456789012
			const string initial = "The quick brown fox ate the poor, wimpy dog.";
			using (TextBox txt = new TextBox())
			{
				txt.Text = initial;
				txt.SelectionStart = 34;
				txt.SelectionLength = 5;
				Assert.IsTrue(txt.MoveSelectedWord(false));
				//               0         1         2         3         4
				//               0123456789012345678901234567890123456789012
				Assert.AreEqual("The quick brown fox ate the wimpy poor, dog.", txt.Text);
				Assert.AreEqual(28, txt.SelectionStart);
				Assert.AreEqual(6, txt.SelectionLength);
			}
		}
開發者ID:bbriggs,項目名稱:FieldWorks,代碼行數:18,代碼來源:TextBoxExtensionsTests.cs

示例7: MoveSelectedWord_IpInWordBeforeComma

		public void MoveSelectedWord_IpInWordBeforeComma()
		{
			//                      0         1         2         3         4
			//                      0123456789012345678901234567890123456789012
			const string initial = "The quick brown fox ate the poor, wimpy dog.";
			using (TextBox txt = new TextBox())
			{
				txt.Text = initial;
				txt.SelectionStart = 29;
				txt.SelectionLength = 0;
				Assert.IsTrue(txt.MoveSelectedWord(true));
				//               0         1         2         3         4
				//               0123456789012345678901234567890123456789012
				Assert.AreEqual("The quick brown fox ate the wimpy poor, dog.", txt.Text);
				Assert.AreEqual(33, txt.SelectionStart);
				Assert.AreEqual(6, txt.SelectionLength);

				txt.Text = initial;
				txt.SelectionStart = 29;
				txt.SelectionLength = 0;
				Assert.IsTrue(txt.MoveSelectedWord(false));
				//               0         1         2         3         4
				//               0123456789012345678901234567890123456789012
				Assert.AreEqual("The quick brown fox ate poor, the wimpy dog.", txt.Text);
				Assert.AreEqual(24, txt.SelectionStart);
				Assert.AreEqual(6, txt.SelectionLength);
			}
		}
開發者ID:bbriggs,項目名稱:FieldWorks,代碼行數:28,代碼來源:TextBoxExtensionsTests.cs

示例8: MoveSelectedWord_Normal_SingleWordSelected_BackwardToStart_NoPunctuation

		public void MoveSelectedWord_Normal_SingleWordSelected_BackwardToStart_NoPunctuation()
		{
			//                      0         1         2         3         4
			//                      0123456789012345678901234567890123456789012
			const string initial = "The quick brown fox ate the poor wimpy dog";
			using (TextBox txt = new TextBox())
			{
				// Start with second-to-last word
				txt.Text = initial;
				int prevStart = txt.SelectionStart = 33;
				txt.SelectionLength = 5;
				int steps = 0;
				while (txt.MoveSelectedWord(false))
				{
					Assert.IsTrue(prevStart > txt.SelectionStart);
					Assert.AreEqual(6, txt.SelectionLength);
					prevStart = txt.SelectionStart;
					steps++;
				}
				Assert.AreEqual(7, steps);
				Assert.AreEqual("wimpy The quick brown fox ate the poor dog", txt.Text);
				Assert.AreEqual(0, txt.SelectionStart);
				Assert.AreEqual(6, txt.SelectionLength);

				// Start with last word
				txt.Text = initial;
				prevStart = txt.SelectionStart = 39;
				txt.SelectionLength = 3;
				steps = 0;
				while (txt.MoveSelectedWord(false))
				{
					Assert.IsTrue(prevStart > txt.SelectionStart);
					Assert.AreEqual(4, txt.SelectionLength);
					prevStart = txt.SelectionStart;
					steps++;
				}
				Assert.AreEqual(8, steps);
				//               0         1         2         3         4
				//               0123456789012345678901234567890123456789012
				Assert.AreEqual("dog The quick brown fox ate the poor wimpy", txt.Text);
				Assert.AreEqual(0, txt.SelectionStart);
				Assert.AreEqual(4, txt.SelectionLength);
			}
		}
開發者ID:bbriggs,項目名稱:FieldWorks,代碼行數:44,代碼來源:TextBoxExtensionsTests.cs

示例9: MoveSelectedWord_Normal_SingleWordSelected_BackwardToStart_InitialPunctuation

		public void MoveSelectedWord_Normal_SingleWordSelected_BackwardToStart_InitialPunctuation()
		{
			// 0         1         2         3         4
			// 01234567890123456789012345678901234567890123456
			// ?Por que' comio' el zorro al pobre perro debil?
			const string initial = "\u00BFPor que\u0301 comio\u0301 el zorro al pobre perro debil?";
			using (TextBox txt = new TextBox())
			{
				txt.Text = initial;
				int prevStart = txt.SelectionStart = 41;
				txt.SelectionLength = 5;
				int steps = 0;
				while (txt.MoveSelectedWord(false))
				{
					Assert.IsTrue(prevStart > txt.SelectionStart);
					Assert.AreEqual(6, txt.SelectionLength);
					prevStart = txt.SelectionStart;
					steps++;
				}
				Assert.AreEqual(8, steps);
				Assert.AreEqual("\u00BFdebil Por que\u0301 comio\u0301 el zorro al pobre perro?", txt.Text);
				Assert.AreEqual(1, txt.SelectionStart);
				Assert.AreEqual(6, txt.SelectionLength);
			}
		}
開發者ID:bbriggs,項目名稱:FieldWorks,代碼行數:25,代碼來源:TextBoxExtensionsTests.cs

示例10: MoveSelectedWord_Normal_SingleWordSelected_ForwardToEnd_NoPunctuation

		public void MoveSelectedWord_Normal_SingleWordSelected_ForwardToEnd_NoPunctuation()
		{
			const string initial = "The quick brown fox ate the poor wimpy dog";
			using (TextBox txt = new TextBox())
			{
				// Start with second word
				txt.Text = initial;
				int prevStart = txt.SelectionStart = 4;
				txt.SelectionLength = 5;
				int steps = 0;
				while (txt.MoveSelectedWord(true))
				{
					Assert.IsTrue(prevStart < txt.SelectionStart);
					Assert.AreEqual(6, txt.SelectionLength);
					prevStart = txt.SelectionStart;
					steps++;
				}
				Assert.AreEqual(7, steps);
				//               0         1         2         3         4
				//               0123456789012345678901234567890123456789012
				Assert.AreEqual("The brown fox ate the poor wimpy dog quick", txt.Text);
				Assert.AreEqual(36, txt.SelectionStart);
				Assert.AreEqual(6, txt.SelectionLength);

				// Start with first word
				txt.Text = initial;
				prevStart = txt.SelectionStart = 0;
				txt.SelectionLength = 3;
				steps = 0;
				while (txt.MoveSelectedWord(true))
				{
					Assert.IsTrue(prevStart < txt.SelectionStart);
					Assert.AreEqual(4, txt.SelectionLength);
					prevStart = txt.SelectionStart;
					steps++;
				}
				Assert.AreEqual(8, steps);
				//               0         1         2         3         4
				//               0123456789012345678901234567890123456789012
				Assert.AreEqual("quick brown fox ate the poor wimpy dog The", txt.Text);
				Assert.AreEqual(38, txt.SelectionStart);
				Assert.AreEqual(4, txt.SelectionLength);
			}
		}
開發者ID:bbriggs,項目名稱:FieldWorks,代碼行數:44,代碼來源:TextBoxExtensionsTests.cs

示例11: MoveSelectedWord_Normal_SingleWordSelected_ForwardToEnd_FinalPunctuation

		public void MoveSelectedWord_Normal_SingleWordSelected_ForwardToEnd_FinalPunctuation()
		{
			const string initial = "The quick brown fox ate\u0301 the poor wimpy dog.";
			using (TextBox txt = new TextBox())
			{
				txt.Text = initial;
				int prevStart = txt.SelectionStart = 4;
				txt.SelectionLength = 5;
				int steps = 0;
				while (txt.MoveSelectedWord(true))
				{
					Assert.IsTrue(prevStart < txt.SelectionStart);
					Assert.AreEqual(6, txt.SelectionLength);
					prevStart = txt.SelectionStart;
					steps++;
				}
				Assert.AreEqual(7, steps);
				// 0         1         2         3         4
				// 01234567890123456789012345678901234567890123
				// The brown fox ate' the poor wimpy dog quick.
				Assert.AreEqual("The brown fox ate\u0301 the poor wimpy dog quick.", txt.Text);
				Assert.AreEqual(37, txt.SelectionStart);
				Assert.AreEqual(6, txt.SelectionLength);
			}
		}
開發者ID:bbriggs,項目名稱:FieldWorks,代碼行數:25,代碼來源:TextBoxExtensionsTests.cs

示例12: MoveSelectedWord_Normal_SingleWordSelected_BackwardThenForward

		public void MoveSelectedWord_Normal_SingleWordSelected_BackwardThenForward()
		{
			const string initial = "The quick brown fox ate the poor wimpy dog.";
			using (TextBox txt = new TextBox())
			{
				txt.Text = initial;
				txt.SelectionStart = 10;
				txt.SelectionLength = 5;
				Assert.IsTrue(txt.MoveSelectedWord(false));
				Assert.AreEqual("The brown quick fox ate the poor wimpy dog.", txt.Text);
				Assert.AreEqual(4, txt.SelectionStart);
				Assert.AreEqual(6, txt.SelectionLength);

				Assert.IsTrue(txt.MoveSelectedWord(true));
				Assert.AreEqual(initial, txt.Text);
				Assert.AreEqual(10, txt.SelectionStart);
				Assert.AreEqual(6, txt.SelectionLength);
			}
		}
開發者ID:bbriggs,項目名稱:FieldWorks,代碼行數:19,代碼來源:TextBoxExtensionsTests.cs

示例13: MoveSelectedWord_OneWord_SpaceAfter_StartOfWordSelected

		public void MoveSelectedWord_OneWord_SpaceAfter_StartOfWordSelected()
		{
			const string initial = "dog ";
			using (TextBox txt = new TextBox())
			{
				txt.Text = initial;
				txt.SelectionStart = 0;
				txt.SelectionLength = 2;
				Assert.IsTrue(txt.MoveSelectedWord(true));
				Assert.AreEqual("g do", txt.Text);
				Assert.AreEqual(2, txt.SelectionStart);
				Assert.AreEqual(2, txt.SelectionLength);

				txt.Text = initial;
				txt.SelectionStart = 0;
				txt.SelectionLength = 2;
				Assert.IsFalse(txt.MoveSelectedWord(false));
				Assert.AreEqual(initial, txt.Text);
			}
		}
開發者ID:bbriggs,項目名稱:FieldWorks,代碼行數:20,代碼來源:TextBoxExtensionsTests.cs

示例14: MoveSelectedWord_OneWord_SpaceAfter_IPBeforeSpace

		public void MoveSelectedWord_OneWord_SpaceAfter_IPBeforeSpace()
		{
			const string initial = "dog ";
			using (TextBox txt = new TextBox())
			{
				txt.Text = initial;
				txt.SelectionStart = 3;
				txt.SelectionLength = 0;
				Assert.IsTrue(txt.MoveSelectedWord(true));
				Assert.AreEqual(" dog", txt.Text);
				Assert.AreEqual(1, txt.SelectionStart);
				Assert.AreEqual(3, txt.SelectionLength);

				txt.Text = initial;
				txt.SelectionStart = 3;
				txt.SelectionLength = 0;
				Assert.IsFalse(txt.MoveSelectedWord(false));
				Assert.AreEqual(initial, txt.Text);
			}
		}
開發者ID:bbriggs,項目名稱:FieldWorks,代碼行數:20,代碼來源:TextBoxExtensionsTests.cs


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