I use TMemo to be able to display multiple lines.
I want to change selected text attribute in TMemo into bold using the shortcut Ctrl+B.
For example, User enters “Hello, how are you?” in the Tmemo, I want when when user selects “How” and press Ctrl+B then only “How” should be appeared in Bold in that TMemo.
I use Delphi 7.
Please advice to get solution. thanks for help.
You can’t format text in a memo control. You need a rich edit control,
TRichEdit.In order to make the current selection bold you do this:
The preferred way to invoke code in response to a shortcut like CTRL+A is to use actions. Add a
TActionListto the form and add an action to that action list. Set the action’sOnExecuteevent handler to point at code that performs the bolding of the selected text. Set theShortcutproperty toCtrl+A. Use actions so that you can centralise the control of user events. Typically there may also be a tool button, a menu item and a context menu item that performed the same action and this is where actions come into their own.