Windows Forms: SelectionChanged event for TextBox

2019-01-19 00:12发布

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)?

3条回答
地球回转人心会变
2楼-- · 2019-01-19 00:45

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

查看更多
趁早两清
3楼-- · 2019-01-19 00:45

You can use TextBox also.

Write a funktion GetMyPosition() and put in the events

  • TextChanged()
  • MouseClick()
  • KeyUp() (In KeyDown() the position isn't changed)

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

查看更多
淡お忘
4楼-- · 2019-01-19 00:58

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

查看更多
登录 后发表回答