我有一个combobox,其下拉列表中有四项值,如:'美国';'中国';'日本';‘韩国’。现如今我怎么来判断我的combobox.text取值是美国,从而根据该判断来打开一个数据表。
谢谢。

解决方案 »

  1.   

    添加一个button在其onclick事件写代码
    if combobox.text='美国' then
    begin
      ...
      adoquery.sql.add('select * from t where A=''美国''');
      ...
    End else
    ...或者在combobox的onchange事件写代码,不用管它选的是什么:
    adoquery.sql.add('select * from t where A='+Quotedstr(combobox.text));或者美国,中国…是表名称
    if Trim(combobox.text)<>'' then
      adoquery.sql.add('select * from '+Quotedstr(combobox.text));
      

  2.   

    procedure TForm1.ComboBox1Change(Sender: TObject);
    begin
    if combobox1.text='美国' then
    begin
      做你的事情
    end;
    end;