• Sign in to Neowin Faster!

    Create an account on Neowin to contribute and support the site.

  • 0

[Delphi] Problem with SaveToFile

Question

tetsu-kun    1
Posted (edited)

Hey guys.

I'm having a problem with my code, ok I explain me more. I have the next visual design:

RAD.thumb.png.68c7b12a0a8980e4627684910dd092e0.png 

 

In my SaveDialog button I have the next code (added on the "Exportar" button):

procedure Button2Click(Sender: TObject);
var
  i: integer;
  strT: string;
  slst: TStringList;
begin                             
  slst:= TStringList.Create;
Try     
  With DBGrid1.DataSource.DataSet Do  
  begin                              
      First;
    while not Eof do   
    begin
      strT:= '"'+Fields[0].AsString+'"';
      for i:= 1 to FieldCount-1 do
        strT:= strT+',"'+Fields[i].AsString+'"';
      slst.Add(strT);               
      Next;
    end; 
          First;    
  end;   
  if SaveDialog1.Execute(0)then 
      slst.SaveToFile(SaveDialog1.filename);
Finally         
  slst.Free;
End;   
         
end; 

And its save me only the DBGrid, but I wanna save the full file, I mean, the Columns and content of the DBGrid and the operation result (on the bottom).

Can anybody explain me how to do it or what I'm doing wrong, please?

Thanks.

Regards.

Share this post


Link to post
Share on other sites

3 answers to this question

Recommended Posts

  • 0
+Code Name: Lockdown    9,237

Wow, I didn't realise that Deplhi was still a language people used!  I always remember it being a competitor to VB6 (rightly or wrongly)

Share this post


Link to post
Share on other sites
  • 0
tetsu-kun    1
1 minute ago, Human.Online said:

Wow, I didn't realise that Deplhi was still a language people used!  I always remember it being a competitor to VB6 (rightly or wrongly)

Jajaja neither do I, but the report system that I use comes with this language and I need to know how can I do solve it 😛 I tried in some ways but I can't get the full report like I need it. That's the reason why I'm using Delphi jajaja, it's not because I wanna, it's because the system comes with it jajaja.

Regards.

  • Like 1

Share this post


Link to post
Share on other sites
  • 0
tetsu-kun    1

¿Cualquiera? : /

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   1 member

    • +virtorio