RE:Modificar el alto de celdas de un Stringgrid
El TStringGrid es una herramienta más poderosa de lo que en un principio parece. Sin embargo, no tiene una propiedad como WordWrap
El poder que menciono viene cuando nos atrevemos a cambiar el valor de la propiedad DefaultDrawing en False.
Luego de eso viene la pelea por 'pintar' el grid.
Esto se hace en el evento OnDrawCell.
Aquí una aproximación a lo que quieres hacer:
procedure TForm1.Grid1(Sender: TObject; ACol, ARow: Integer; Rect: TRect;
State: TGridDrawState);
const
nLINEAS: Integer = 2; //Dos líneas es lo que quieres, pero podrías ponerle más.
var
aLineas: array[1..nLINEAS] of String;
i, nPosX, nPosY: Integer;
oCentrado: TPoint;
begin
for i := 1 to 3 do
begin
//Procedimiento para llenar el array con 3 strings
//Dado que el string de la celda está dado por Grid1.Cells[ACol, ARow]
end;
nPosY := 2 + Rect.Left;
if (gdSelected in State) or (gdFocused in State) then //Para las celdas seleccionadas
begin
Grid1.Canvas.Brush.Color := clWebBeige;
Grid1.Canvas.Brush.Style := bsSolid;
Grid1.Canvas.Pen.Style := psSolid;
Grid1.Canvas.Pen.Width := 3;
Grid1.Canvas.Pen.Color := clDkGray;
Grid1.Canvas.Rectangle(Rect);
Grid1.Canvas.FillRect(rect);
Grid1.Canvas.Font.Color := clWindowText;
Grid1.Canvas.Font := Grid1.Font;
for i := 1 to 3 do
begin
nPosX := ((i - 1) * 17) + 2 + Rect.Top;
Grid1.Canvas.TextOut(nPosX, nPosY, aLineas[i]);
end;
end
else
if State = [gdFixed] then //Para las celdas de tílulo
begin
Grid1.Canvas.Brush.Style := bsSolid;
Grid1.Canvas.Brush.Color := clBtnFace;
Grid1.Canvas.Font.Color := clWindowText;
Grid1.Canvas.Font := Grid1.Font;
Grid1.Canvas.Font.Style := [fsBold];
Grid1.Canvas.FillRect(Rect);
Grid1.Canvas.Pen.Color := clBtnHighlight;
Grid1.Canvas.Rectangle(Rect);
Grid1.Canvas.Pen.Color := clBtnShadow;
Grid1.Canvas.Polyline([point(Rect.Left, Rect.Bottom-1),
point(Rect.Right-1, Rect.Bottom-1),
point(Rect.Right-1, Rect.Top)]);
oCentrado.X :=
Trunc((Rect.Right - Rect.Left - Grid1.Canvas.TextWidth(Grid1.Cells[ACol, ARow])) / 2);
oCentrado.Y :=
Trunc((Rect.Bottom - Rect.Top - Grid1.Canvas.TextHeight(Grid1.Cells[ACol, ARow])) / 2);
Grid1.Canvas.TextOut(Rect.Left + oCentrado.X, Rect.Top + oCentrado.Y,
Grid1.Cells[ACol, ARow]);
end
else //Para las demás celdas
begin
Grid1.Canvas.Brush.Color := clWindow;
Grid1.Canvas.Brush.Style := bsSolid;
Grid1.Canvas.Pen.Style := psSolid;
Grid1.Canvas.Pen.Width := 1;
Grid1.Canvas.Pen.Color := clDkGray;
Grid1.Canvas.Rectangle(Rect);
Grid1.Canvas.FillRect(rect);
Grid1.Canvas.Font.Color := clWindowText;
Grid1.Canvas.Font := Grid1.Font;
for i := 1 to 3 do
begin
nPosX := ((i - 1) * 17) + 2 + Rect.Top;
Grid1.Canvas.TextOut(nPosX, nPosY, aLineas[i]);
end;
end;
end;
No he probado el código, pero bien te puede dar una idea de lo que puedes hacer.
Si te pones a investigar un poco, hayarás, incluso, la forma de insertar imágenes y crearles sus propios eventos de mouse, etc.
Saludos.