Supongo ya solucionaste tu problema, para otros foristas interesados, lo siguiente puede ser una solución:
Código Delphi
[-]
procedure TForm2.FormCreate(Sender: TObject);
begin
Grilla.ColCount := 10;
Grilla.Cells[0,0] := 'Titulo 1';
Grilla.Cells[1,0] := 'Titulo 2';
Grilla.Cells[2,0] := 'Titulo 2';
Grilla.Cells[3,0] := 'Titulo 4';
Grilla.Cells[4,0] := 'Titulo 5';
Grilla.Cells[5,0] := 'Titulo 6';
Grilla.Cells[6,0] := 'Titulo 7';
Grilla.Cells[7,0] := 'Titulo 8';
Grilla.Cells[8,0] := 'Titulo 9';
Grilla.Cells[9,0] := 'Titulo 10';
Grilla.ColWidths[0] := 65;
Grilla.ColWidths[1] := 70;
Grilla.ColWidths[2] := 70;
Grilla.ColWidths[3] := Grilla.ColWidths[2];
Grilla.ColWidths[4] := Grilla.ColWidths[2];
Grilla.ColWidths[5] := 75;
Grilla.ColWidths[6] := Grilla.ColWidths[5];
Grilla.ColWidths[7] := 85;
Grilla.ColWidths[8] := 70;
end;
procedure TForm2.FormResize(Sender: TObject);
var
i: byte;
c: word;
begin
c := 0;
for i := 0 to Grilla.ColCount - 2 do
c := c + Grilla.ColWidths[i];
Grilla.ColWidths[Grilla.ColCount - 1] := Grilla.Width - c - 35; end;
procedure TForm2.GrillaDrawCell(Sender: TObject; ACol, ARow: Integer; Rect: TRect; State: TGridDrawState);
var
Alineacion : TAlignment; F : Cardinal;
begin
with Grilla.Canvas do
begin Font.Name := Grilla.Font.Name;
Font.Size := Grilla.Font.Size;
if ARow = 0 then begin Font.Style := [fsBold]; Alineacion := taCenter
end else
if ACol = 0 then Alineacion := taRightJustify
else Alineacion := taCenter;
if gdFixed in State then begin Brush.Color := clNavy; Font.Color := clWhite end else begin
if gdFocused in State then begin if (pos('clave por si se quiere otro color el la celda enfocada', LowerCase(Grilla.Cells[3,aRow])) > 0) then
Brush.Color := clFuchsia else if (pos('otra palabra clave', LowerCase(Grilla.Cells[2,aRow])) > 0) then
Brush.Color := clGreen else Brush.Color := clRed; Font.Color := clWhite; Font.Style := [fsBold] end else begin Brush.Color := clWindow;
Font.Color := clBlack;
Font.Style := []
end
end;
FillRect(Rect);
F := DT_SINGLELINE or DT_VCENTER or DT_NOPREFIX or DT_END_ELLIPSIS;
if Grilla.Cells[aCol,aRow] <> '' then begin
case Alineacion of
taLeftJustify : F := F or DT_LEFT;
taCenter : F := F or DT_CENTER;
taRightJustify: F := F or DT_RIGHT
end;
setbkmode(Handle, 0);
DrawText (Handle, Grilla.Cells[ACol,ARow], -1, Rect, F)
end
end
end;
esto lo probé en delphi XE4