type
TForm1 = class(TForm)
ListBox1: TListBox;
ComboBox1: TComboBox;
ListBox2: TListBox;
Button1: TButton;
Edit1: TEdit;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;procedure TForm1.Button1Click(Sender: TObject);
var
SQLS,tmp :string;
i,j,linenum :integer;
begin
case combobox1.ItemIndex of
0:tmp:= 'SO2';
1:tmp:= 'NO';
2:tmp:= 'NO2';
3:tmp:= 'NOX';
4:tmp:= 'CO';
5:tmp:= 'O3';
6:tmp:= 'PM10';
7:tmp:= 'CO2';
else
tmp:= 'SO2';
end;
SQLS:='select ';
for i:= 1 to listbox1.SelCount do //listbox中可能多选
begin
if (i>1) and (i<=listbox1.SelCount) then SQLS:= SQLS+',';
//此处可以显示Listbox的有关属性
SQLS:=SQLS+tmp;//此处简化便于显示
//从此处开始Listbox的有关属性不能显示????????
end;
........
end;
调试了几个小时,还是不明白?请教,感谢
我的目的是想得到选中的ITEM的索引值
TForm1 = class(TForm)
ListBox1: TListBox;
ComboBox1: TComboBox;
ListBox2: TListBox;
Button1: TButton;
Edit1: TEdit;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;procedure TForm1.Button1Click(Sender: TObject);
var
SQLS,tmp :string;
i,j,linenum :integer;
begin
case combobox1.ItemIndex of
0:tmp:= 'SO2';
1:tmp:= 'NO';
2:tmp:= 'NO2';
3:tmp:= 'NOX';
4:tmp:= 'CO';
5:tmp:= 'O3';
6:tmp:= 'PM10';
7:tmp:= 'CO2';
else
tmp:= 'SO2';
end;
SQLS:='select ';
for i:= 1 to listbox1.SelCount do //listbox中可能多选
begin
if (i>1) and (i<=listbox1.SelCount) then SQLS:= SQLS+',';
//此处可以显示Listbox的有关属性
SQLS:=SQLS+tmp;//此处简化便于显示
//从此处开始Listbox的有关属性不能显示????????
end;
........
end;
调试了几个小时,还是不明白?请教,感谢
我的目的是想得到选中的ITEM的索引值
for I := 0 to ListBox1.Items.Count - 1 do
begin
if ListBox1.Selected[I] then
begin
SQLS := SQLS + ',';
SQLS := SQLS + tmp;
//...ListBox1.Items[I]
end;
end;
sql:string;
begin
sql:='select';
for i:=0 to listbox1.Count-1 do
begin
if listbox1.Selected[i] then
sql:=sql+' '+listbox1.Items.Strings[i]+',';
end;
if rightstr(sql,1)=',' then
sql:=leftstr(sql,length(sql)-1);
listbox1.
end;
listbox1.
end;
........
end;
var
SQLS,tmp :string;
i,j,linenum :integer;
begin
case combobox1.ItemIndex of
0:tmp:= 'SO2'; // 这行可以不是,因为已经在 Else 里了,或者Else不是了
1:tmp:= 'NO';
2:tmp:= 'NO2';
3:tmp:= 'NOX';
4:tmp:= 'CO';
5:tmp:= 'O3';
6:tmp:= 'PM10';
7:tmp:= 'CO2';
else
tmp:= 'SO2';
end;
SQLS := ''
for i:= 0 to listbox1.Count - 1 do
if listbox1.Selected[i] then SQLS:= SQLS + ', ' + listbox1.Items.Strings[i];
if SQLS[1] = ',' then Delete(SQLS, 1, 1);
SQLS := 'Select' + SQLS + ' from ' + tmp;
........
end;