设置ComboBox的默认选择项:
//在Form的创建事件中添加
this->ComboBox1->ItemIndex = 1;
编写搜索事件:
//SQL语句如果用精确查询用=,模糊查找用Like加通配符
void __fastcall Tfrproductmanage::Button1Click(TObject *Sender)
{
//
int index = this->ComboBox1->ItemIndex;
String szColumns = this->ComboBox1->Items->Strings[index];
String szEdit = this->Edit1->Text;
DataModule1->FDQuery1->Open("SELECT TOP (1000) [货号],[条码] ,[拼音编码],[品名],[规格] ,[单位],[产地],[类别],[进货价],[销售价1],[销售价2],[最低售价] FROM [jxcbook].[dbo].[商品清单] where [" + szColumns + "] like '%" + szEdit + "%'");
}