窗体上有16个Combobox和16个Edit,分别一一对应,每个Combobox的Items都是一样的(设计阶段就已设置了所有的Items),Combobox用来显示科目名,对应的Edti用来显示成绩,那么怎样让用ADOQuery选出来的记录对应到各个Combobox和Edit,选出的记录一定是小于或等于16个,比如选出的记录如下:数学 82.0
历史 95.0
音乐 100.0
物理 85.0
语文 82.0
化学 92.0那么就要把科目名依次放到各个Combobox中显示,“数学”放在Combobox1,并且对应的Edit显示数学分数82.0,“历史”放在Combobox2,等等一次类推。
历史 95.0
音乐 100.0
物理 85.0
语文 82.0
化学 92.0那么就要把科目名依次放到各个Combobox中显示,“数学”放在Combobox1,并且对应的Edit显示数学分数82.0,“历史”放在Combobox2,等等一次类推。
解决方案 »
- database desktop
- WebBrowser复制图片到剪贴板问题?急,,急,,,在线等!!!
- 好久没来散分...自由了...UP都有分
- 高价请人做一套外贸客户管理软件
- 这样才可以屏蔽输入法右边的小键盘按钮?
- 在PaintBox中画的线,为什么没了?
- 我的窗口为什么每弹出一个窗口闪得厉害呢
- 请教ShellListView的问题,还望大家多多指教!
- 求代码调用winzip应用程序解码*.eml文件为*.txt文件?
- 求Delphi XE7VCL源码
- 我用虚拟驱动器的方法在一台电脑上使用另一台电脑上的ACCESS数据库,但在使用中如果网络断了,数据库也破坏了不能用了,怎办?
- 读取注册表键值的问题?(binary和DWord类型的)
i := 1;
while not ADOQuery1.Eof do
begin
TCombobox(FindComponent('Combobox' + inttostr(i))).text := ADOQuery1.FieldByName('科目名').asstring;
TEdit(FindComponent('Edit' + inttostr(i))).text := ADOQuery1.FieldByName('分数名').asstring;
ADOQuery1.next;
i := i + 1;
end;
之后,就用楼上的方法
adoquery1.sql.clear;
adoquery1.sql.add('select * from tablename');
adoquery1.open;
if combobox1.text='数学' then edit1.text:=adoquery1.parambyname('数学').value;
;;;;
;;;;;
;;;;;
类推
不知道能帮你吗?
如果各科成绩在一条记录的话 直接select * from yourtable 就行了
如果各科成绩不在一条记录的话 sql语句要复杂一点点
ADOQuery1.first;
i := 1;
while not ADOQuery1.Eof do
begin
TCombobox(FindComponent('Combobox' + inttostr(i))).text := ADOQuery1.FieldByName('科目名').asstring;
TEdit(FindComponent('Edit' + inttostr(i))).text := ADOQuery1.FieldByName('分数名').asstring;
ADOQuery1.next;
TCombobox(FindComponent('Combobox' + inttostr(i))).visible := true ;
TEdit(FindComponent('Edit' + inttostr(i))).visible := true ;
i := i + 1;
end;