2011-07-17 39 views

回答

7

要突出顯示一行,必須使用OnSpecialLineColors事件。你可以創建一個函數來找到該行的字(檢查這個問題Is There An Efficient Whole Word Search Function in Delphi?),然後畫線

檢查這個代碼

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; 
+1

謝謝!這個事件何時被調用? – maxfax

+2

事件由Synedit組件調用,每次更改該行的數據。 – RRUZ