窗体上有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,等等一次类推。

解决方案 »

  1.   

    用TDBCombobox 和TDBEDIT,连接到数据源就可以了!
      

  2.   

    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;
      i := i + 1;
    end;
      

  3.   

    Select * From .... Order By 成绩
    之后,就用楼上的方法
      

  4.   

    adpquery1.close;
    adoquery1.sql.clear;
    adoquery1.sql.add('select * from tablename');
    adoquery1.open;
    if combobox1.text='数学' then edit1.text:=adoquery1.parambyname('数学').value;
    ;;;;
    ;;;;;
    ;;;;;
    类推
    不知道能帮你吗?
      

  5.   

    用TDBCombobox 和TDBEDIT
    如果各科成绩在一条记录的话 直接select * from yourtable 就行了
    如果各科成绩不在一条记录的话 sql语句要复杂一点点
      

  6.   

    开始的时候应该是visible都是false
    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;