winforms - How to find the position of a single word of text in a form C# -


i'm not sure if possible or not. i'm interested in being able find (x,y) position of word of text on winform.

for example, in picture below, want able pull (x,y) coordinate of upper-left hand corner of letter h in "here".

i know how position of textbox, can make rough estimate based off of word "here" inside textbox, able ask program word if possible.

also, if there way position, i'd able length , height of word (basically want know coordinates of bounding box of word "here" if possible)

not sure if matters, textbox richtextbox, , textbox populated string array in form1 class.

thank in advance!

enter image description here

you can use getpositionfromcharindex method, position of "here" within textbox or richtextbox (it works both).

as know, position in window have sum position of richtextbox. this:

int index = richtextbox1.text.indexof("here"); point textboxlocation = richtextbox1.getpositionfromcharindex(index); point windowslocation = new point(richtextbox1.location.x + textboxlocation.x, richtextbox1.location.y + textboxlocation.y); console.writeline("position in textbox: " + textboxlocation.tostring()); console.writeline("position in window: " + windowslocation.tostring()); 

Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -