0

Richtextbox has a function GetCharIndexFromPosition, which can be used to retrieves the index of the character nearest to the specified location.

But label has no such function, I am wondering if it is possible for it.

For example: given the position (0,200), and we want to get the char index "d" of the label.

enter image description here

camino
  • 10,085
  • 20
  • 64
  • 115
  • `GetCharIndexFromPosition` is declared in `TextBoxBase`, so I guess a brute force way to do this would be to create a text box with the same text and size as your label, and calling `GetCharIndexFromPosition` on the text box... – Sweeper Jan 26 '19 at 16:20
  • 1
    You can use a read-only textbox having selection disabled. Then you can use `GetCharIndexFromPosition` as suggested by Sweeper. Look at [this post](https://stackoverflow.com/a/42391380/3110834). – Reza Aghaei Jan 26 '19 at 16:24
  • 1
    Sweeper, Reza Aghaei, Good idea, Thanks! – camino Jan 26 '19 at 16:36

0 Answers0