How to quickly remove duplicates from RichEdit1? This way removes very slowly:

procedure TForm1.Button1Click(Sender: TObject); var i: integer; begin i := 0; while i < RichEdit1.Lines.Count do begin if RichEdit1.Lines.IndexOf(RichEdit1.Lines[i]) < i then RichEdit1.Lines.Delete(i) else inc(i); end; end; 

    1 answer 1

    Fast crutch substitute - wrap the operation in BeginUpdate/EndUpdate

    But, probably, there is a better solution, which depends on the real problem.
    For example - where do duplicates come from?

    • Duplicates there because of the fact that there I carry out the parsing of information from the network. And RichEdit can put more information into it than Memo. - craz2018
    • In this case, use TStringList, not a visual component. - MBo
    • Already done, it was interesting with the visual component. - craz2018
    • Fast way - with a sorted list, because there is no need to go through each line to search for matches. - Alekcvp pm