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 21-08-2015
wilcg wilcg is offline
Miembro
 
Registrado: abr 2014
Posts: 107
Poder: 11
wilcg Va por buen camino
Flotantes en campo DBGridEh mediante evento

Amigos del foro tengo este codigo en el evento OnDrawColumnCell de un DBGridEh por corregir algunos puntos.
Código Delphi [-]
procedure DBGridEhDrawColumnCell(Sender: TObject; const Rect: TRect;
  DataCol: Integer; Column: TColumnEh; State: TGridDrawState);
const
  // Windwos classic
  CtrlState: Array[Boolean] of Integer = (DFCS_BUTTONCHECK, DFCS_BUTTONCHECK or
  DFCS_CHECKED);
  // Windows xp
  CtrlStateXP: Array [Boolean] of TThemedButton = (tbCheckBoxUncheckedNormal,
  tbCheckBoxCheckedNormal);
var
  R      : TRect;
  uFormat: LongWord;
  Details: TThemedElementDetails;
begin
  uFormat := DT_SINGLELINE or DT_VCENTER or DT_END_ELLIPSIS;
  case Column.Alignment of
    taLeftJustify : uFormat := uFormat or DT_LEFT;
    taRightJustify: uFormat := uFormat or DT_RIGHT;
    taCenter      : uFormat := uFormat or DT_CENTER;
  end;

  with TDBGridEh(Sender) do
  begin
    if Datasource.DataSet.RecNo mod 2 = 0 then
      Canvas.Brush.Color := $00F5F5F5
    else
      Canvas.Brush.Color := clWhite;
    Canvas.Font.Color := $00606060;

    if gdSelected in State then
   begin
     Canvas.Brush.Color := $00A6E8FF;
     Canvas.Font.Color := clHotLight;
     Canvas.Font.Name := 'Tahoma';
     Canvas.Font.Size := 9;
   end ;
    DefaultDrawColumnCell(rect,DataCol,Column,State);
    R := Rect;
   Canvas.FillRect(R);
   DrawText(Canvas.Handle, @Column.Field.AsString[1], -1, R, uFormat);
   // Campo Booleano
   if Column.Field.DataType = ftBoolean then
   begin
     Canvas.FillRect(Rect);
     if ThemeServices.ThemesEnabled then
     begin
       Details := ThemeServices.GetElementDetails(CtrlStateXP[Column.Field.AsBoolean]);
       ThemeServices.DrawElement(Canvas.Handle, Details, Rect);
     end else
     begin
       R.Left   := Rect.Left + 2;
       R.Right  := Rect.Right - 2;
       R.Top    := Rect.Top + 2;
       R.Bottom := Rect.Bottom - 2;
       DrawFrameControl(Canvas.Handle, R, DFC_BUTTON, CtrlState[Column.Field.AsBoolean]);
     end;
   end;
  end;
end;
Lo que hace es:
Primero ajusta el texto del campo a su longitud y muestra 3 puntitos
Segundo Dibuja un checkbox en cada campo booleano.

luego viene lo que quiero, es que formatee un campo numerico ejemplo S/. 123.00 lo he estado
haciendo en la propiedad del DisplayFormat del campo, aparentemente funciona sin el codigo. Luego con
el codigo en el evento OnDrawColumnCell del DBGridEh no funciona.
espero que me hayan entendido y me puedan ayudar.
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
Saber si un campo existe mediante sql falla tarco35 Conexión con bases de datos 5 12-07-2015 05:42:57
Consultar el campo precio mediante el codigo de un producto GABOCABALLERO Conexión con bases de datos 6 17-10-2010 17:30:55
Insertar imagen en campo blob mediante SQL saulpm MS SQL Server 12 12-10-2010 15:35:33
obtener campo de varios obtenidos de sql mediante un cursor jesusvp SQL 5 16-07-2007 20:35:57
Filtrar tabla Interbase mediante campo fecha Neomanar Conexión con bases de datos 3 12-09-2005 15:11:19


La franja horaria es GMT +2. Ahora son las 08:05:22.


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