procedure TFormKcsp.SpeedButton5Click(Sender: TObject);//子类
var
FormKcsp2:TFormKcsp;
begin
FormKcsp2:=TFormKcsp.Create(self);//要想子窗口和父窗口错位,那父窗口的Position需设置成poDesigned
with FormKcsp2.ADOQuery1 do
begin
FormKcsp2.ADOQuery1.Connection:=FormLogin.ADOConnection1;
FormKcsp2.ADOQuery1.SQL.Clear;
if Trim(ADOQuery1.FieldByName('id').AsString)<>'' then
begin
FormKcsp2.ADOQuery1.SQL.Add('select * from kcsp where parentID='''+ADOQuery1.FieldByName('id').AsString+'''');
end
else
begin
exit;
end;
FormKcsp2.ADOQuery1.Open;
end;
FormKcsp2.Top:=self.Top+20;
FormKcsp2.Left:=self.Left+20;
FormKcsp2.ShowModal;
FormKcsp2.Free;
end;
我是这样打开子窗口的,然后子窗口里打开修改窗口,修改后怎么刷新这个子窗口的数据?
var
FormKcsp2:TFormKcsp;
begin
FormKcsp2:=TFormKcsp.Create(self);//要想子窗口和父窗口错位,那父窗口的Position需设置成poDesigned
with FormKcsp2.ADOQuery1 do
begin
FormKcsp2.ADOQuery1.Connection:=FormLogin.ADOConnection1;
FormKcsp2.ADOQuery1.SQL.Clear;
if Trim(ADOQuery1.FieldByName('id').AsString)<>'' then
begin
FormKcsp2.ADOQuery1.SQL.Add('select * from kcsp where parentID='''+ADOQuery1.FieldByName('id').AsString+'''');
end
else
begin
exit;
end;
FormKcsp2.ADOQuery1.Open;
end;
FormKcsp2.Top:=self.Top+20;
FormKcsp2.Left:=self.Left+20;
FormKcsp2.ShowModal;
FormKcsp2.Free;
end;
我是这样打开子窗口的,然后子窗口里打开修改窗口,修改后怎么刷新这个子窗口的数据?
所以你可以这样写:
From2.ShowModal;
DataSet.Close;
DataSet.Open;