Ver Mensaje Individual
  #14  
Antiguo 20-01-2016
shoulder shoulder is offline
Miembro
 
Registrado: abr 2008
Posts: 441
Reputación: 19
shoulder Va por buen camino
dbgrid wrap

Hola lo que busco es el wrap no el autosize, lo encontre pero a mi no me funciona, les paso el ejemplo y el link, pero me entra en un loop infinito, es decir al fijar el ancho de columna el campo agranda el alto de la fila para que entre todo ahi. Probe toda la mañana veo en el loop que me lo hace pero no corta. En sistensis seria el mutiline de una fila de dbgrid.






Código Delphi [-]
type
  THackDBGrid = class (TDBGrid)
  public
    property RowHeights;
  end;

procedure TFormx.DBGrid3DrawColumnCell(Sender: TObject; const Rect: TRect;
  DataCol: Integer; Column: TColumn; State: TGridDrawState);

var
  HackGrid: THackDBGrid;
  Ind: Integer;
  lRec: TRect;
  Str: AnsiString;
  DS: TDataSet;
  uForm, uCurr: Cardinal;
  NH, valor: Integer;
begin
    DS  := (Sender As TDBGrid).DataSource. DataSet;
    Ind := DS.RecNo;
    Str := DS.FieldByName (Column.FieldName).DisplayText;
    lRec := Rect;
    lRec.Left := lRec. Left + 1;
    lRec.Right:= lRec. Right - 1;
    (Sender As TDBGrid).Canvas. FillRect (lRec);
    NH := lRec. Bottom - lRec.Top;
    //Set an alignment to the text in the cell
    case Column. Alignment of
      taLeftJustify: uForm := DT_SINGLELINE or DT_LEFT;
      taRightJustify: uForm:= DT_SINGLELINE or DT_RIGHT;
      taCenter: uForm:= DT_SINGLELINE or DT_CENTER;
    end;
    //Set an advanced alignment to the text in the cell (Tag value of the field is used)
    valor := DS.FieldByName(Column.FieldName).DataSize;


    if valor > 50 then
     begin
       uForm := DT_WORDBREAK or DT_CALCRECT;
       NH := DrawText ((Sender As TDBGrid).Canvas. Handle, PAnsiChar (Str),-1, lRec,     uCurr)    + 2;
       uForm := DT_WORDBREAK;
       lRec.Bottom := lRec.Top + NH;
       HackGrid:= THackDBGrid (DBGrid3);
       HackGrid.RowHeights[Ind]:= NH;

      uCurr:= uForm;
      DrawText ((Sender As TDBGrid).Canvas. Handle, PAnsiChar (Str),-1, lRec, uCurr);

     end;

el link original esta aqui.

http://www.delphipages.com/forum/sho...d.php?t=216440

o

http://www.progtown.com/topic106385-...ne-dbgrid.html
Responder Con Cita