Insert text as bold

General TRichView support forum. Please post your questions here
Post Reply
dakota
Posts: 35
Joined: Tue Jan 13, 2009 11:25 pm

Insert text as bold

Post by dakota »

Hi:

All I'm trying to do is insert three lines of text into a TDBRichViewEdit, with the first one being bold. (the second two lines are just cr's for spacing). I must be suffering from severe brain fade today because I just cant get it.

(If you provide an answer, please speak slowly... and provide lots of detail as I'm kind of slow to pick things up sometimes!)


Here's what I have so far

Code: Select all

  {Move to beginning of document}
  ItemNo := 0;
  Offs := RV.GetOffsBeforeItem(ItemNo);
  RV.SetSelectionBounds(ItemNo, Offs, itemNo, Offs);

  {Insert the text}
  RV.InsertText('My text goes here' + #13#13#13, cCaretBefore_False);

  {HOW DO I MAKE IT BOLD? (1st line only)}

  {Now position caret on second line and return focus to RichViewEdit}
  RVSetLinearCaretPos(RV, Length(sText)- 2);
  RV.SetFocus;
Also, supposed I wanted instead to make the text larger, and with a different color?

Thanks,

Dale
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Add a text style with the desired properties in TRVStyle component linked with this RichViewEdit, and assign its index to CurTextStyleNo property before calling InsertText:

Code: Select all

  {Insert the text} 
  RV.CurTextStyleNo := <index of style in RV.Style.TextStyles>;
  RV.InsertText('My text goes here' + #13#13#13, cCaretBefore_False);
Post Reply