Ver Mensaje Individual
  #3  
Antiguo 12-11-2008
Dark_RavenM Dark_RavenM is offline
Miembro
 
Registrado: dic 2007
Posts: 25
Reputación: 0
Dark_RavenM Va por buen camino
respuesta

Me ayudaron con el problema con este codigo, todos los creditos a su autor paco

Debe estar ligado al evento OnDblClick de tu StringGrid.

Código Delphi [-]
procedure TfrmCatalogos.StringGrid1DblClick(Sender: TObject); 
var 
  rAnt: TRect; 
  oMousePt: TPoint; 
  nRow, nCol, nWidth, nWidthMax: Integer; 
begin 

  oMousePt := Mouse.CursorPos; 
  oMousePt := StringGrid1.ScreenToClient(oMousePt); 

  for nCol := 1 to StringGrid1.ColCount - 1 do 
    begin 
      rAnt := StringGrid1.CellRect(nCol,0); 
      if (oMousePt.X >= rAnt.Right - 3) and 
        (oMousePt.X <= rAnt.Right + 4) and 
        (oMousePt.Y in [rAnt.Top..rAnt.Bottom]) then 
        begin 
          nWidthMax := 0; 
          for nRow := 0 to (StringGrid1.RowCount - 1) do begin 
            if nRow = 0 then //El header es bold 
              StringGrid1.Canvas.Font.Style := [fsBold] 
            else //Las demás líneas no son bold 
              StringGrid1.Canvas.Font.Style := []; 
            nWidth := StringGrid1.Canvas.TextWidth(StringGrid1.Cells[nCol, nRow]); 
            if nWidth > nWidthMax then 
              nWidthMax := nWidth; 
          end; 
          StringGrid1.ColWidths[nCol] := nWidthMax + 5; 
        end; 
    end; 

end;

Última edición por Neftali [Germán.Estévez] fecha: 13-11-2008 a las 10:41:21.
Responder Con Cita