Page 1 of 1

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

Posted: Sat Oct 13, 2007 11:28 am
by Jmich
How I can a marked table-cell the cell-color alter

Posted: Sat Oct 13, 2007 2:08 pm
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.