主题:急就一个字
lzahn
[专家分:50] 发布于 2006-05-27 15:46:00
有人知道怎么设置dbcombobox
让它的items中的值是数据库中有的...(自动添加到ITEMS中)....
急......
回复列表 (共1个回复)
沙发
hanwb2002 [专家分:1340] 发布于 2006-05-29 17:59:00
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Mask, DBCtrls, DB, ADODB, Grids, DBGrids;
type
TForm1 = class(TForm)
DBGrid1: TDBGrid;
ADOQuery1: TADOQuery;
DataSource1: TDataSource;
DBComboBox1: TDBComboBox;
Button2: TButton;
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button2Click(Sender: TObject);
var
I:Integer;
s:string;
begin
ADOQuery1.SQL.Add('select * from ytsw_glory');
ADOQuery1.Close;
ADOQuery1.Open;
ADOQuery1.First;
while not ADOQuery1.Eof do
begin
s:=ADOQuery1.fieldbyName('ftitle').asstring;
DBComboBox1.Items.Add(s);
ADOQuery1.Next;
end;
end;
随便写了一些,你自己再改一下吧
我来回复