Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > Varios
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Grupo de Teaming del ClubDelphi

 
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 01-04-2015
Avatar de olbeup
olbeup olbeup is offline
Miembro
 
Registrado: jul 2005
Ubicación: Santiago de la Ribera (España)
Posts: 685
Poder: 19
olbeup Va camino a la fama
StringGrid, Dibujar mas de una celda o columna

Hola Compañer@s,

A la hora de dibujar un cuadrado en una o varias celdas de un StingGrid no hay ningún problemas.
El problema está cuando selecciona la celda que tiene dibujado mas de una celda y sólo me dibuja la primera, no veo la luz al final del tunel.

Código Delphi [-]
procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
  Rect: TRect; State: TGridDrawState);
var
  objSG: TGridCell;
  SndSG: TStringGrid;
  RectDraw, RectText: TRect;
begin
  SndSG := (Sender as TStringGrid);

  RectDraw := Rect;
    InflateRect(RectDraw, -1, -1);

  RectText := RectDraw;
    InflateRect(RectText, -1, -1);

  objSG := (SndSG.Objects[ACol, ARow] as TGridCell);

  if (not Assigned(objSG)) then
    Exit;

  case objSG.Alignment of
    taLeftJustify:
      Inc(RectText.Left, 2);
    taRightJustify:
      Dec(RectText.Right, 2);
  end;

  with SndSG do
  begin
    if (ACol = objSG.CoordCell.Col) and (ARow = objSG.CoordCell.Row) and (objSG.CoordCell.ColUnion <= 0) then
      Exit;

    if (ACol = objSG.CoordCell.Col) and (ARow = objSG.CoordCell.Row) and (objSG.CoordCell.ColUnion > 1) then
    begin
      RectDraw.Right := (RectDraw.Right + objSG.CoordCell.ColUnion -1) + (objSG.CoordCell.DefaultColWidth * (objSG.CoordCell.ColUnion -1));
      RectText.Right := RectDraw.Right;
    end;

    if (gdSelected in State) then
      Canvas.RoundRect(RectDraw.Left, RectDraw.Top, RectDraw.Right, RectDraw.Bottom, 3, 3) <--- AQUÍ ES CUANDO DIBUJA SOLO UNA CUANDO TIENE QUE DIBUJAR MAS DE UNA
    else
      Canvas.Rectangle(RectDraw);  <--- AQUÍ LO HACE BIEN

    DrawText(Canvas.Handle, PChar(objSG.TextCell), StrLen(PChar(objSG.TextCell)), RectText, objSG.DrawAlign OR DT_VCENTER OR DT_SINGLELINE);
  end;
end;
Un saludo.
__________________
Al hacer una consulta SQL, haz que los demás te entiendan y disfruten de ella, será tú reflejo de tú saber.

Última edición por olbeup fecha: 01-04-2015 a las 13:56:24.
Responder Con Cita
 



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
¿como dibujar texto en un stringgrid? JXJ Varios 2 21-10-2014 00:18:55
Como dibujar una celda, fila o columna en un DBGrid Alexandro Varios 5 24-10-2008 12:24:31
Dibujar encabezado Columna TDBGrid eureka OOP 3 21-11-2005 03:02:44
Dibujar imagen con ImageList en StringGrid neon OOP 1 20-12-2004 18:24:44
Como Pintar Solo la Celda y No Toda la Columna de la Celda de un dbGrid?? AGAG4 Varios 11 15-11-2004 20:53:28


La franja horaria es GMT +2. Ahora son las 23:06:32.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi