How I can a marked table-cell the cell-color alter

General TRichView support forum. Please post your questions here
Post Reply
Jmich
Posts: 19
Joined: Mon Apr 30, 2007 10:10 am

How I can a marked table-cell the cell-color alter

Post by Jmich »

How I can a marked table-cell the cell-color alter
Sergey Tkachenko
Site Admin
Posts: 17565
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Do you want to know how to change background color for selected cells?
This code makes the selected cells red (as an editing operation):

Code: Select all

procedure TForm1.Color1Click(Sender: TObject);
var rve: TCustomRichViewEdit;
  table: TRVTableItemInfo;
  r,c,i: Integer;
begin
  if not RichViewEdit1.CanChange or
     not RichViewEdit1.GetCurrentItemEx(TRVTableItemInfo, rve,
       TCustomRVItemInfo(table)) then
    exit;
  rve.BeginUndoGroup(rvutModifyItem);
  rve.SetUndoGroupMode(True);
  try
    for r := 0 to table.RowCount-1 do
      for c := 0 to table.ColCount-1 do
        if (table.Cells[r,c]<>nil) and (table.IsCellSelected(r,c)) then
          table.SetCellColor(clRed, r,c);
  finally
    rve.SetUndoGroupMode(False);
  end;
  rve.Change;
end;
Or do you want to use another color to highlight selection?
In this case, see properties of TRVStyle: SelColor, SelTextColor, InactiveSelColor, InactiveSelTextColor.
Post Reply