Answer the question
In order to leave comments, you need to log in
Coloring StringGrrid Delphi, Color Preservation?
There is a StringGrid on the form. There is a custom function that prepares variables for use in the DrawCell event of the StringGrid object.
procedure SetColor(ARow, ACol : integer; Col : TColor);
begin
SC := True;
AR := ARow; //Строка (Глобальные переменные)
AC := ACol; //Столбец
CL := Col; //Цвет
Form1.StringGrid1.Refresh;
SC := False;
end;
...
if step > 0 then //Если step больше нуля, вычисляем предыдущую ячейку и закрашиваем её в желтый цвет
SetColor(cl,(cindex+((step-1) * (step-1))), clYellow);
SetColor(cl, ind, clBlue); //Текущую ячейку закрашиваем в синий цвет cl - строка, ind - столбец.
...
...
if SC then
if (ARow = CL) and (ACol = AC) then
Canvas.Brush.Color:=CL;
Canvas.FillRect(Rect);
Canvas.TextRect (Rect,Rect.Left,Rect.Top,Cells[ACol,ARow]);
Canvas.TextRect (Rect,Rect.Left+2,Rect.Top+2,Cells[ACol,ARow]);
...
Answer the question
In order to leave comments, you need to log in
How do you keep the color?Create an array of filled cells. Use
OnDrawCell
.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question