J
jobsxy
Unregistered / Unconfirmed
GUEST, unregistred user!
以下代码可以正确执行:
procedure TForm1.Button1Click(Sender: TObject);
var s : string;
begin
combobox1.Clear;
s := '01';
combobox1.Items.AddObject('北京',TObject(s));
s := '02';
end;
procedure TForm1.ComboBox1Change(Sender: TObject);
begin
edit1.Text := string(combobox1.Items.Objects[combobox1.ItemIndex]);
end;
而以下代码却不能正确执行,是什么原因呢?
procedure TForm1.Button1Click(Sender: TObject);
var s : string;
begin
combobox1.Clear;
with table1 do begin
s := fieldsbyname('id').asstring;
combobox1.Items.AddObject(fieldbyname('name').asstring, TObject(s));
end;
end;
procedure TForm1.ComboBox1Change(Sender: TObject);
begin
edit1.Text := string(combobox1.Items.Objects[combobox1.ItemIndex]);
end;
procedure TForm1.Button1Click(Sender: TObject);
var s : string;
begin
combobox1.Clear;
s := '01';
combobox1.Items.AddObject('北京',TObject(s));
s := '02';
end;
procedure TForm1.ComboBox1Change(Sender: TObject);
begin
edit1.Text := string(combobox1.Items.Objects[combobox1.ItemIndex]);
end;
而以下代码却不能正确执行,是什么原因呢?
procedure TForm1.Button1Click(Sender: TObject);
var s : string;
begin
combobox1.Clear;
with table1 do begin
s := fieldsbyname('id').asstring;
combobox1.Items.AddObject(fieldbyname('name').asstring, TObject(s));
end;
end;
procedure TForm1.ComboBox1Change(Sender: TObject);
begin
edit1.Text := string(combobox1.Items.Objects[combobox1.ItemIndex]);
end;