var checkbox1:TCheckBox; begin checkbox1:=TCheckBox.Create(self); checkbox1.Parent:=dbgrd1; end; 事件的话,就自己写过程,然后checkbox1事件等于改过程,前提是过程的参数得和checkbox1事件参数相同。
procedure TForm1.FormCreate(Sender: TObject); var checkbox1:TCheckBox; begin checkbox1:=TCheckBox.Create(self); checkbox1.Parent:=DBGrid1; with ADOQuery1 do begin close; sql.Clear; sql.Add('select top 10 * from tbname'); open; end; end;你看看这样对吗?
checkbox1:TCheckBox;
begin
checkbox1:=TCheckBox.Create(self);
checkbox1.Parent:=dbgrd1;
end;
事件的话,就自己写过程,然后checkbox1事件等于改过程,前提是过程的参数得和checkbox1事件参数相同。
procedure TForm1.FormCreate(Sender: TObject);
var
checkbox1:TCheckBox;
begin
checkbox1:=TCheckBox.Create(self);
checkbox1.Parent:=DBGrid1; with ADOQuery1 do
begin
close;
sql.Clear;
sql.Add('select top 10 * from tbname');
open;
end;
end;你看看这样对吗?
方法如下:
对于Boolean型字段值在dbgrideh组件中自动显示为检查框。通常情况下我们需将非Boolean型字段值也此外观显示,如性别字段为字符型,字段值为“男性”时为选中,“女性”时为未选中。需要在keylist编辑器中设置实际存储数据值,第一行为选中时的值“1”,第二行为未选中的值 “0”,第三行为其它值“2”,支持三态显示。
http://delphi.about.com/od/usedbvcl/l/aa082003a.htm
我前幾天試做成功了.