Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Auto select all text in a RTF Textbox without using Ctrl+A?

Status
Not open for further replies.

kamweng

Programmer
Jan 20, 2012
36
0
0
MY
In a normal textbox I could use the format property "K" to auto select all the text when it got focus but this property is not availabe in a RTF textbox.

Maybe I missed knowing about another property that is similar to the format property.

Anyway, is there a way to get all the text in a RTF textbox selected when it got focus without using Ctrl+A?


 
Thank you for your reply.

Yes, it worked but the text did not stay selected. It just flashed as selected and then become unselected. Happily this saved me another click to unselect the text because when the text was selected, I have reformated the text as required.

Thank you again for your help.
 
>when the text was selected, I have reformated the text as required.
Well, that is most probably causing the text to not be kept selected. In general just setting selstart and sellength selects text and it stays selected. Either the formatting command you used or some other default behaviour of the focus events was deselecting the text, but you can simply check the general persistence of selection by creating a test command button only setting selstart and sellength to some values making sense and not set focus to the rtf textbox.

If you then set focus with the mouse the normal thing happens, if you click on a document with selected text, the selection is removed and the text cursor positions moves to the mouse position, that also happens in notepad or word. Text selection really is just text selection, it's not permanently coloring text foreground and background.

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top