Windows窗体:TextBox类的SelectionChanged事件

时间:2022-01-06 15:51:24

How do I get notified of a selection change in a text box in .NET 2.0? I was unable to find a SelectionChanged event or an OnSelectionChanged method. What is the best workaround for this (without having to PInvoke, of course)?

如何在.NET 2.0的文本框中收到选择更改的通知?我无法找到SelectionChanged事件或OnSelectionChanged方法。对此最好的解决方法是什么(当然不需要PInvoke)?

3 个解决方案

#1


6  

You could use a RichTextBox and set Multiline to false. It has a OnSelectionChanged.

您可以使用RichTextBox并将Multiline设置为false。它有一个OnSelectionChanged。

#2


2  

Well, I guess this may help! You will need to use RichTextBox still.

好吧,我想这可能会有所帮助!您仍需要使用RichTextBox。

#3


0  

You can use TextBox also.

您也可以使用TextBox。

Write a funktion GetMyPosition() and put in the events

写一个funktion GetMyPosition()并放入事件中

  • TextChanged()
  • 框TextChanged()
  • MouseClick()
  • 鼠标点击()
  • KeyUp() (In KeyDown() the position isn't changed)
  • KeyUp()(在KeyDown()中位置没有改变)

When you want to notify the highliting of a text, you also have to use - MouseHover()

当您想要通知文本的高位时,您还必须使用 - MouseHover()

#1


6  

You could use a RichTextBox and set Multiline to false. It has a OnSelectionChanged.

您可以使用RichTextBox并将Multiline设置为false。它有一个OnSelectionChanged。

#2


2  

Well, I guess this may help! You will need to use RichTextBox still.

好吧,我想这可能会有所帮助!您仍需要使用RichTextBox。

#3


0  

You can use TextBox also.

您也可以使用TextBox。

Write a funktion GetMyPosition() and put in the events

写一个funktion GetMyPosition()并放入事件中

  • TextChanged()
  • 框TextChanged()
  • MouseClick()
  • 鼠标点击()
  • KeyUp() (In KeyDown() the position isn't changed)
  • KeyUp()(在KeyDown()中位置没有改变)

When you want to notify the highliting of a text, you also have to use - MouseHover()

当您想要通知文本的高位时,您还必须使用 - MouseHover()