实在不行:看我的笨招 1。先将记录集合写到一个下拉框中。 while not AdoQuery1.Eof do begin if AdoQuery1.FieldValues['ParamName']<>NULL then begin sParamName:=AdoQuery1.FieldValues['ParamName']; end else sParamName:=''; if (trim(sParamName)<>'') and (AdoQuery1.FieldValues['ParamName']<>NULL) then ComboBox1.Items.Add(sParamName); AdoQuery1.Next; end; 2。设置默认的项为第一项 combobox2.ItemIndex:=0; DBLookupComboBox1.KeyValue:=combobox2.Text;
2.cxDBComboBox1.ItemIndex赋值,这样修改了数据的内容并显示了你的默认值
我要的是默认选中下拉值中的第一个,而知道第一个值是什么。
还有,我用的是DBLookupComboBox!
1。先将记录集合写到一个下拉框中。
while not AdoQuery1.Eof do begin
if AdoQuery1.FieldValues['ParamName']<>NULL then begin
sParamName:=AdoQuery1.FieldValues['ParamName'];
end else sParamName:='';
if (trim(sParamName)<>'') and (AdoQuery1.FieldValues['ParamName']<>NULL) then ComboBox1.Items.Add(sParamName);
AdoQuery1.Next;
end;
2。设置默认的项为第一项
combobox2.ItemIndex:=0;
DBLookupComboBox1.KeyValue:=combobox2.Text;
比如两个表 人员和部门 人员表里面有一个部门编号,那么如果lookupcobbox如果关联显示部门名称的话,就是主表头一个人的部门,而无法显示部门的第一个值