Fórum como adicionar um checkbox na grid #171363

25/07/2003

0

Ola alguem poderia me ajudar como adicionar um check box na grid

Obrigado

Felipe


Fcremm

Fcremm

Responder

Posts

25/07/2003

Paulo Oliveira

DbCheckBox dentro de uma DbGrid

object DbCheckBox
Caption = ´Senior´
DataField = ´Senior´
DataSource = DataSource1
ValueChecked = ´True´
ValueUnChecked = ´False´
Visible = ´False´


dbGrid

procedure TDbaForm.DBGrid1DrawColumnCell(Sender: TObject;
const Rect: TRect; DataCol: Integer; Column: TColumn;
State: TGridDrawState);
begin
if (gdFocused in State) and
(Column.Field = Table1Senior) then
begin
DBCheckBox1.SetBounds (
Rect.Left + DBGrid1.Left + 1,
Rect.Top + DBGrid1.Top + 1,
Rect.Right - Rect.Left,
Rect.Bottom - Rect.Top);
end;
end;

procedure TDbaForm.DBGrid1ColEnter(Sender: TObject);
begin
if DBGrid1.Columns [DBGrid1.SelectedIndex].
Field = Table1Senior then
DBCheckBox1.Visible := True
else
DBCheckBox1.Visible := False;
end;

procedure TDbaForm.DBGrid1KeyPress(Sender: TObject; var Key: Char);
begin
if DBCheckBox1.Visible and (Ord (Key) > 31) then
begin
Key := #0;
Table1.Edit;
DBCheckBox1.Checked := not
DBCheckBox1.Checked;
DBCheckBox1.Field.AsBoolean :=
DBCheckBox1.Checked;
end;
end;

duvida me envie uma Meng. falo


Responder

Gostei + 0

Utilizamos cookies para fornecer uma melhor experiência para nossos usuários, consulte nossa política de privacidade.

Aceitar