S
ssh78
Unregistered / Unconfirmed
GUEST, unregistred user!
我发现下面的代码如果没有case x of 2...,就正确执行。
var
x:integer;
....
procedure TForm1.BitBtn2Click(Sender: TObject);
begin
if (DBTreeView1.Selected <> Nil) then
begin
case x of 1:
with DBTreeView1.Items.AddChild(DBTreeView1.Selected,DBGrid1.Fields[0].AsString+' '+DBGrid1.Fields[1].AsString)do
begin
table1.edit;
table1.FieldByName('company').AsInteger:=DBGrid1.Fields[0].AsInteger;
table1.post;
end;
case x of 2:
with DBTreeView1.Items.AddChild(DBTreeView1.Selected,DBGrid1.Fields[0].AsString+' '+DBGrid1.Fields[1].AsString) do
begin
table1.edit;
table1.fieldbyname('user').AsInteger:=DBGrid1.fields[0].AsInteger;
table1.post;
end;
end;
end;
end;
var
x:integer;
....
procedure TForm1.BitBtn2Click(Sender: TObject);
begin
if (DBTreeView1.Selected <> Nil) then
begin
case x of 1:
with DBTreeView1.Items.AddChild(DBTreeView1.Selected,DBGrid1.Fields[0].AsString+' '+DBGrid1.Fields[1].AsString)do
begin
table1.edit;
table1.FieldByName('company').AsInteger:=DBGrid1.Fields[0].AsInteger;
table1.post;
end;
case x of 2:
with DBTreeView1.Items.AddChild(DBTreeView1.Selected,DBGrid1.Fields[0].AsString+' '+DBGrid1.Fields[1].AsString) do
begin
table1.edit;
table1.fieldbyname('user').AsInteger:=DBGrid1.fields[0].AsInteger;
table1.post;
end;
end;
end;
end;