当前位置: 首页>>代码示例>>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;未经允许,请勿转载。