Page 1 of 1

Insert text as bold

Posted: Fri Apr 17, 2009 8:40 pm
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

Posted: Sat Apr 18, 2009 6:44 pm
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);