J
Joe Cool
Is there any way to determine the location on the screen where the
currently selected text of a RichTextBox control is at?
currently selected text of a RichTextBox control is at?
No. For one thing, the selection might not be on the screen; it might have
been scrolled far away.
Eq.
What, do you think Microsoft Word is made by dragging a few pre-designed
components onto a form?
To be fair: there must be *some* way to do this, but knowing the screen
position of a selection is not a common requirement, and I'd be very, very
surprised if .NET offers anything to do it.
You probably need to look up some details of the internals of RichTextBox,
and try to manipulate those things using API calls (via
System.Runtime.InteropServices). It will be messy and annoying.
No. For one thing, the selection might not be on the screen; it might have
been scrolled far away.
Thanks for the HideSelection property tip. Worked great. And once I
had that working, I see now that if the text found is on an area not
currently on the screeen, the RichTextBox automatically scrolls until
it is.
But I need to know the physical location as it may be under the find
dialog and if it is, I want to shift the position of the dialog box so
the found text is now visible.
That doesn't do what he asked.
The poster wants to determine the screen
location (i.e. a Point in pixels, or a Region, etc.) of the currently
selected text -- not to move it or display it.
Nope, it was in his second, unrelated thread about "Finding Text in a
RichTextBox".
He wrote: "I need to know the physical location as it may be under the
find
dialog and if it is, I want to shift the position of the dialog box so
the
found text is now visible." How would you do that entire task with
ScrollToCaret?
And that is part of the problem, if the selected text is not on the
screen I want to scroll the RichTextBox with code until the selected
text is on the screen.
I know this can be done as I have seen a commercial application do it.
Hell, Microsoft Word can do it.