对每一个选中的项目,分别生成一个条件,然后你可以根据需要,使用and或者or连接起来。
str_where := '';
for i := 0 to GroupBox1.ControlCount - 1 do
begin
if TCheckBox(GroupBox1.Controls[i]).Checked then
begin
if str_where <> '' then
str_where := ' and ';
str_where := str_where + TCheckBox(GroupBox1.Controls[i]).Caption + ' in ' + QuotedString(str_value);
end;
end;