Fórum Checkbox no dbGrid #192786
04/11/2003
0
Alguém sabe como posso colocar um checkbox ou dbcheckbox dentro do dbgrid????
Obrigado,
Delphi2003
Obrigado,
Delphi2003
Delphi2003
Curtir tópico
+ 0
Responder
Posts
04/11/2003
Leanribas
se vc quiser eu posso mandar dois exemplos para o seu e-mail, qualquer coisa entre em contato no e-mail leandroribas@onda.com.br
Responder
Gostei + 0
04/11/2003
Marcelo.c
Insira um DBCheckBox sobre o DBGrid e defina o campo desejado.
No evento OnDrawColumnCell coloque o código:
if (gdFocused in State) and (Column.Field = Campo) then
begin
DBCheckbox1.SetBounds(
Rect.Left + DBGrid1.Left + 1,
Rect.Top + DBGrid1.Top + 1,
Rect.Right - Rect.Left,
Rect.Bottom - Rect.Top);
end;
No evento OnCollEnter:
if DBGrid1.Columns[DBGrid1.SelectedIndex].Field = Campo then
DBCheckbox1.Visible := True
else
DBCheckBox1.Visible :=False;
E por fim, no evento OnKeyPress:
if DBCheckBox1.Visible and (Ord(Key) > 31) then
begin
Key :=#0;
Table1.Edit;
DBCheckBox1.Checked := not DBCheckBox1.Checked;
DBCheckBox1.Field.AsBoolean := DBCheckBox1.Checked;
end;
No evento OnDrawColumnCell coloque o código:
if (gdFocused in State) and (Column.Field = Campo) then
begin
DBCheckbox1.SetBounds(
Rect.Left + DBGrid1.Left + 1,
Rect.Top + DBGrid1.Top + 1,
Rect.Right - Rect.Left,
Rect.Bottom - Rect.Top);
end;
No evento OnCollEnter:
if DBGrid1.Columns[DBGrid1.SelectedIndex].Field = Campo then
DBCheckbox1.Visible := True
else
DBCheckBox1.Visible :=False;
E por fim, no evento OnKeyPress:
if DBCheckBox1.Visible and (Ord(Key) > 31) then
begin
Key :=#0;
Table1.Edit;
DBCheckBox1.Checked := not DBCheckBox1.Checked;
DBCheckBox1.Field.AsBoolean := DBCheckBox1.Checked;
end;
Responder
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)