Hola xdelph
Cita:
Empezado por xdelph
En todos veo el método DrawCell,...
|
Así es. Y no esperes encontrar algún método como DrawRow por que vas a perder tu tiempo...
Para que pintes una fila y permanezca pintada vas a tener que usar una columna adicional para indicar el estado de dicha columna (pintada o no).
Un ejemplo: (pinta de rojo cuando la columna tiene color blanco y viceversa)
Código Delphi
[-]
procedure TForm1.FormCreate(Sender: TObject);
var
c, f: Integer;
begin
with StringGrid1 do
begin
for c := FixedCols to ColCount-1 do
for f:= FixedRows to RowCount-1 do
Cells[c,f] := IntToStr(c+f);
ColCount := ColCount +1 ; ColWidths[ColCount-1] := 0; Options := Options + [goEditing];
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
const
CSELECTED : array[Boolean] of string = ('','x');
begin
with StringGrid1 do
begin
Cells[ColCount-1, Row] := CSELECTED[Cells[ColCount-1, Row] = ''];
Refresh;
end;
end;
procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
const
CCOLORS: array[Boolean] of TColor = (clWindow, clRed);
begin
with TStringGrid(Sender) do
begin
Canvas.Pen.Color := clBlack;
Canvas.Brush.Color := CCOLORS[Cells[ColCount-1, ARow] = 'x'];
Canvas.FillRect(Rect);
Canvas.TextOut(Rect.Left+1, Rect.Top+1, Cells[ACol,ARow]);
end;
end;
Salida:
Saludos
