How to get all words with a determined color from my text ?

General TRichView support forum. Please post your questions here
Post Reply
alexandreq
Posts: 184
Joined: Wed Jan 18, 2012 6:22 pm

How to get all words with a determined color from my text ?

Post by alexandreq »

Hello Sergey,

How could I get all words from my DBSRichViewEdit that is in red color font?

For example:

Each word found in clred font, I will add in a stringList.

It would be very interesting to have this for background color too, that is, each word in background color in clred should add in a StringList.

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

Post by Sergey Tkachenko »

I can explain how to get all red text. You can separate it into words yourself.

Code: Select all

procedure GetRedText(RVData: TCustomRVData);
var i,r,c, StyleNo: Integer;
    table: TRVTableItemInfo;
begin
  for i := 0 to RVData.ItemCount-1 do begin
    StyleNo := RVData.GetItemStyle(i);
    if (StyleNo>=0) and (RVData.GetRVStyle.TextStyles[StyleNo].Color=clRed) then
      // add RVData.GetItemText(i) to string list
    else if StyleNo=rvsTable then begin
      table := TRVTableItemInfo(RVData.GetItem(i));
      for r := 0 to table.RowCount-1 do
        for c := 0 to table.ColCount-1 do
          if table.Cells[r,c]<>nil then
            GetRedText(table.Cells[r,c].GetRVData);
    end;
  end;
end;
alexandreq
Posts: 184
Joined: Wed Jan 18, 2012 6:22 pm

Post by alexandreq »

Sergey,

Yeah, you worked pretty fine.

Now I can collect all words from a determined color.

Have a nice day
Post Reply