Ver Mensaje Individual
  #4  
Antiguo 28-05-2012
ramonibk ramonibk is offline
Miembro
 
Registrado: may 2004
Posts: 193
Reputación: 20
ramonibk Va por buen camino
Bueno mas o menos ya esta.

la solucion ha sido utilizar un Memo que he insertado en la celda del TStringGrid y acto seguido usando el metodo que me a sugerido ecfisa de los metodos multi linea.

En el DrawCell.
Código Delphi [-]
var
  Grid     : TStringGrid;
  Texto  : String;
  R       : TRect;
begin
 Grid := TStringGrid(Sender);
 if (ARow < Grid.FixedRows) or (ACol < Grid.FixedCols)
  then
   Grid.Canvas.Brush.Color := clBtnFace
  else
   Grid.Canvas.Brush.Color := clWhite;
   Grid.Canvas.FillRect(Rect);
   Texto := Grid.Cells[ACol,ARow];
   DrawText( Grid.Canvas.Handle, PChar(Texto), StrLen(PChar(Texto)), Rect, DT_WORDBREAK);
 if (gdSelected in State)and(ACol=1) Then // Si estanos en la columna 1 insertamos el momo en la celda.
   with Memo1 do
    begin
     memo1.Visible := True;
     BringToFront;
     CopyRect(R, Rect);
     R.TopLeft :=     Form1.ScreenToClient(StringGrid1.ClientToScreen(R.TopLeft));
     R.BottomRight := Form1.ScreenToClient(StringGrid1.ClientToScreen(R.BottomRight));
     SetBounds(R.Left, R.Top, R.Right-R.Left, R.Bottom-R.Top);
     Memo1.SetFocus;
    end;
 if ACol <> 1 Then
  Begin
   Memo1.Lines.Text := '';
   Memo1.Visible := False;
  end;

y para terminar. en el evento OnChange del memo
Código Delphi [-]
 StringGrid1.Cells[Col, Row] :=  Memo1.Lines.Text;
 StringGrid1.Options:= StringGrid1.Options+[goRowSizing,goColSizing];

Bueno ya solo queda que si pulsamos Tab saltemos a la siguiente celda de TStringGrid y por supuesto cambiar a altura de la celda según el numero de lineas. y en cuanto lo tenga lo publico para vuestra información.
Responder Con Cita