简体   繁体   中英

How can I select the previous char from the cursor position in a RichTextBox

I am making an combobox that changes the richTextBox's font, and I would like to be able to automatically change the combobox's selection when I click on a specific text in it, matching its font. I thought, it would be appropriate to add an onClick event on the text. This event would take the curent cursor position and make a selection with the range between the previous position and the current. I would be able to get the font from this selection.

If you know how, or can see a better way to complete this, thanks for replying!

You don't need to actually create a selection range, just looking at rtb.SelectionFont.Name will return the font name from the current caret position (ie without needing to select anything)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM