procedure TMainForm.CreateMDIChild(const Name: string);
begin
// Child := TForm1.Create(Application);
if FileExists(Name) then begin
OpenDialog1.InitialDir := ExtractFilePath(Name);
if not OpenTable(Name) then
StatusBar.SimpleText := '错误:"'+Name+'"不是一个合法的数据表!';
end;
end;
{Child}
function OpenTable(TableName: TFileName):Boolean;
begin
with TEditTableFrm.Create(Application) do begin
try
caption := TableName;
Table1.Active := False;
Table1.Filtered := False;
Table1.DatabaseName := ExtractFilePath(TableName);
Table1.SQL.Clear;
TabN := ' from '+''''+ExtractFileName(TableName)+'''';
SQL0 := 'Select * '+ TabN ;
Table1.SQL.Add(SQL0);
Table1.Active := True;
SetLength(fd, Table1.FieldCount);
DBGrid1ColumnMoved(nil,0,0);//刷新fd
ReSult := True;
except
ReSult := False;
Free;
end;
end;
end;