2

I have 20 different words. How to highlight rows with those words in different colors in SynEdit? If it is not possible to highlight rows then just to highlight the words.

Big Thanks!!!!!!

maxfax
  • 4,281
  • 12
  • 74
  • 120

1 Answers1

8

To highlight a row you must use the OnSpecialLineColors Event. You can create a function to find the word in the line (check this question Is There An Efficient Whole Word Search Function in Delphi?) and then paint the line

Check this code

procedure TFrmMain.SynEditCodeSpecialLineColors(Sender: TObject;
  Line: integer; var Special: boolean; var FG, BG: TColor);
begin
  If LineContainsWord(Line) then //here check if the word is in the line
  begin
   FG      := clYellow; //Text Color
   BG      := clBlue; //BackGround
   Special := True; //Must be true
  end;        
end;
Community
  • 1
  • 1
RRUZ
  • 134,889
  • 20
  • 356
  • 483
  • 3
    The event is called by the Synedit component, every time which the data of the line is changed. – RRUZ Jul 17 '11 at 01:29