Ver Mensaje Individual
  #15  
Antiguo 19-07-2005
Avatar de el_barto
el_barto el_barto is offline
Miembro
 
Registrado: may 2005
Ubicación: Bogota Colombia
Posts: 533
Reputación: 19
el_barto Va por buen camino
la segunda no por que uso interbase y no permite crear datos boolean

mira yo tengo este codigo pero tiene dos problemas imprime checkbox fuera de la grilla y no se pueden modificar como en esta.

es decir si el checkbox esta checked no lo puedes pasar a unchecked:


Código Delphi [-]
procedure TForm1.DrawColumnCell(const Rect: TRect; DataCol: Integer;
  Column: TColumn; State: TGridDrawState);
const
  CtrlState: array[Boolean] of Integer = (DFCS_BUTTONCHECK, DFCS_BUTTONCHECK or DFCS_CHECKED);
var
  Exit: boolean;
  IsTrue: boolean;
  CheckBoxRec: TRect;
begin
  // Control del pintado del CheckBox
  Exit := false;

  if not Assigned(Column) or not Assigned(Column.Field) then
    Exit := true;

  // sólo controlamos los campos booleanos o enteros 
  if not Exit and not (Column.Field.DataType in [ftBoolean, ftInteger, ftSmallint]) then
    Exit := true;

  // si el campo es entero, la propiedad Tag de la columna tiene que tener un 1 para imprimir el check
  if ((Column.Field.DataType = ftInteger) or (Column.Field.DataType = ftSmallint)) and
      (Column.Field.Tag = 1) then
    Exit := true;

  // miramos que valor (true/false) hay que asignar al CheckBox
  IsTrue := false;
  if Column.Field.DataType = ftBoolean then
    IsTrue := Column.Field.AsBoolean;
  if ((Column.Field.DataType = ftInteger) or (Column.Field.DataType = ftSmallint)) then
    IsTrue := Column.Field.AsInteger = 1;

  if not Exit then
  begin
    Self.Canvas.FillRect(Rect);
    CheckBoxRec.Left   := Rect.Left + 2;
    CheckBoxRec.Right  := Rect.Right - 2;
    CheckBoxRec.Top    := Rect.Top + 2;
    CheckBoxRec.Bottom := Rect.Bottom - 2;
    DrawFrameControl(Self.Canvas.Handle, CheckBoxRec, DFC_BUTTON, CtrlState[IsTrue]);
  end;
end;

pero el principal problema es que no me imprime el checkbox en la grilla pruebalo y veras
__________________
Una forma de alcanzar tus metas es ayudando a otros a alcanzar las suyas
Responder Con Cita