好像是不行,DataGrid中的字段没出来。
我的代码:
unit MainForm;
interface
uses
Business.System, Business.Forms, Business.Model, Business.Data;
type
TMainForm = class(TForm)
TemplateDate: TUserDataSet;
Button1: TButton;
DataSource1: TDataSource;
DataGrid1: TDataGrid;
procedure Button1Click(Sender: TObject);
private
{private declarations}
public
{public declarations}
MyData: TUserDataSet;
end;
implementation
procedure TMainForm.Button1Click(Sender: TObject);
var
AStream :TStream;
begin
MyData:= TUserDataSet.Create(self);
DataSource1.DataSet := MyData;
AStream := TMemoryStream.Create;
try
TemplateDate.Open;
TemplateDate.SaveToStream(AStream,TDataPacketformat.dfBinary);
AStream.Seek(0, TSeekOrigin.soBeginning);
MyData.LoadFromStream(AStream);
finally
aStream.Free;
end;
end;
end. |