No es que sea muy pronto, se me ha caido una Novell y vengo un poco cansado pero ahí va lo prometido:
DbChkSumar, es un DbCheckBox que está vinculado al campo Tipo booleano
que queremos controlar desde la rejilla, en este caso se trata de
marcar que líneas de la factura queremos que se sumen.
GrLineas, es el nombre que le he dado a la rejilla
Código:
procedure TfrFacturas.GrLineasColEnter(Sender: TObject);
begin
if GrLineas.Columns [GrLineas.SelectedIndex].
Field = DmLux.LinfactSumar then
DbChkSumar.Visible := True
else
DbChkSumar.Visible := False;
end;
procedure TfrFacturas.GrLineasDrawColumnCell(Sender: TObject;
const Rect: TRect; DataCol: Integer; Column: TColumn;
State: TGridDrawState);
begin
if (gdFocused in State) and
(Column.Field = DmLux.LinfactSumar) then
begin
DbchkSumar.SetBounds (
Rect.Left + grLineas.Left + 1,
Rect.Top + grLineas.Top + 1,
Rect.Right - Rect.Left,
Rect.Bottom - Rect.Top);
end;
end;
procedure TfrFacturas.GrLineasKeyPress(Sender: TObject; var Key: Char);
begin
if DbChkSumar.Visible and (Ord (Key) > 31) then
begin
Key := #0;
DmLux.Linfact.Edit;
DbChkSumar.Checked := not
DbChkSumar.Checked;
DbChkSumar.Field.AsBoolean :=
DbChkSumar.Checked;
end;
Un Saludo.