Is there a way to return a point for a string within a text box? I found a COM function GetTextExtentPoint that will return the length of a string, but I want to know the point where the string starts.
相关问题
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- Carriage Return (ASCII chr 13) is missing from tex
- Generic Generics in Managed C++
- Why am I getting UnauthorizedAccessException on th
You're looking for the
GetPositionFromCharIndex
method.what comes to mi mind is to take a snapshot of both the form and text then do some fancy image comparing to find the starting point.. but for this you need to write/download a library that has theese comparing methods... thus becoming very complicated...
why do you need to do this?
First, figure out the index of the first character of the string.
Then use GetPositionFromCharIndex.
(Code not tested, but something like this should work. Of course you will have to deal with the possibility of duplicate occurrences of your string in the textbox.)