unit append_combobox;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Db, DBTables, Grids, DBGrids, ExtCtrls, DBCtrls;
type
TForm1 = class(TForm)
DBGrid1: TDBGrid;
Table1: TTable;
DataSource1: TDataSource;
Button1: TButton;
Edit1: TEdit;
ComboBox1: TComboBox;
Button2: TButton;
Button3: TButton;
DBNavigator1: TDBNavigator;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
{ Private declarations }
function bj(sj:string):boolean;
public
{ Public declarations }
end;
var
Form1: TForm1;
sj:string;
i:integer;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
begin
table1.first;
sj:=table1.fields[0].asstring;
while not table1.eofdo
begin
if bj(sj)=true then
combobox1.items.append(sj);
table1.next;
sj:=table1.fields[0].asstring;
end;
end;
function tform1.bj(sj:string):boolean;
var z:integer;
a:integer;
begin
i:=combobox1.dropdowncount;
a:=combobox1.dropdowncount;
for z:=0 to i-1do
begin
if sj=combobox1.items[z] then
dec(i);
end;
if i<a then
result:=false
else
result:=true;
end;