我用下面的语句存:
cbxSubject.Items.AddObject(qry.FieldByName('FNAME').AsString, TObject(qry.FieldByName('FCODE').AsString));我用string(cbxsubject.items.Objects[0])取出来后,
却发现是乱码。
这是怎么回事啊?

解决方案 »

  1.   

    procedure TForm1.Button1Click(Sender: TObject);
    var
      P:Pstring;
    begin
      New(P);
      P^ := 'ffff';
      ComboBox1.Items.AddObject('aaaa', TObject(P));
    end;procedure TForm1.Button2Click(Sender: TObject);
    begin
      showmessage(ComboBox1.Items[0]);
      showmessage(PString(ComboBox1.Items.Objects[0])^);
      if ComboBox1.Items.Objects[0] <> nil then
      begin
        dispose(PString(ComboBox1.Items.Objects[0]));
        ShowMessage('A');
      end;
    end;
      

  2.   

    STRING 不是TOBJECT就这样另外,comboBox存放的是指针,如一楼!就可以了!
      

  3.   

    string在delphi中是基础类型,不是从tobject继承下来的。当然不能作为object加到combox中去了。