How to Save Stringgrid to diff Filenames lazarus / 31-LCL ---------------------------------------------------------------------- greertr · 2016-11-24 14:29 I have a stringgrid and some radio buttons, and I' m having a problem figuring out how to save/load  stringgrid data to diff filenames depending on which radiobutton is selected Here's the code for the unit... Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i unit Unit3; {$mode objfpc}{$H+} interface uses  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,  CheckLst, ExtCtrls, Grids, ComCtrls, Types; type   { TForm3 }   TForm3 = class(TForm)    Button1: TButton;    Button4: TButton;    Button5: TButton;    Button6: TButton;    CheckListBox2: TCheckListBox;    CheckListBox3: TCheckListBox;    GroupBox1: TGroupBox;    GroupBox2: TGroupBox;    GroupBox3: TGroupBox;    GroupBox4: TGroupBox;    Image1: TImage;    Image2: TImage;    Label1: TLabel;    Label3: TLabel;    OpenDialog1: TOpenDialog;    ProgressBar1: TProgressBar;  RadioButton1: TRadioButton;    RadioButton10: TRadioButton;    RadioButton11: TRadioButton;    RadioButton12: TRadioButton;    RadioButton13: TRadioButton;    RadioButton14: TRadioButton;    RadioButton15: TRadioButton;    RadioButton2: TRadioButton;    RadioButton3: TRadioButton;    RadioButton4: TRadioButton;    RadioButton5: TRadioButton;    RadioButton6: TRadioButton;    RadioButton7: TRadioButton;    RadioButton8: TRadioButton;    RadioButton9: TRadioButton;    SaveDialog1: TSaveDialog;    StringGrid1: TStringGrid;    procedure Button4Click(Sender: TObject);    procedure Button5Click(Sender: TObject);    procedure Button6Click(Sender: TObject);    procedure FormCreate(Sender: TObject);    procedure ProgressBar1ContextPopup(Sender: TObject; MousePos: TPoint;      var Handled: Boolean);  private    { private declarations }  public    { public declarations }   end;    //Class Helper  var  Form3: TForm3; implementation {$R *.lfm} { TForm3 } procedure TForm3.ProgressBar1ContextPopup(Sender: TObject; MousePos: TPoint;  var Handled: Boolean);begin end; procedure TForm3.Button4Click(Sender: TObject);begin  Form3.Visible := False;end; procedure TForm3.Button5Click(Sender: TObject);begin // if OpenDialog1.Execute then //   StringGrid2.LoadFromFile(OpenDialog1.FileName);  end; procedure TForm3.Button6Click(Sender: TObject);begin  if SaveDialog1.Execute then    StringGrid1.SaveToFile(SaveDialog1.FileName);end; procedure TForm3.FormCreate(Sender: TObject);begin end; end. procedure TForm3.SaveItemsToFile(aCheckListBox: TCheckListBox;  const aFilename: string);begin end; procedure TForm3.LoadItemsFromFile(aCheckListBox: TCheckListBox;  const aFilename: string);begin end;  any ideas? thx in adv Greer T. ---------------------------------------------------------------------- greertr · 2016-11-24 15:49 just noting a partial solution here...I figured out how to prepopulate the filename field in the opensave dialog boxes based on a radiobutton being checked. the following code sniped gets the job done Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm3.Button5Click(Sender: TObject);begin If (radiobutton1.checked=true) then   OpenDialog1.Filename := 'HeliTour.xml'; if OpenDialog1.Execute then   StringGrid1.LoadFromFile(OpenDialog1.FileName);end; procedure TForm3.Button6Click(Sender: TObject);begin  If (radiobutton1.checked=true) then   SaveDialog1.Filename := 'HeliTour.xml';  if SaveDialog1.Execute then    StringGrid1.SaveToFile(SaveDialog1.FileName);end; Now I'll figure out how to a case statement ionstead of 20 if- then...lol Greer ---------------------------------------------------------------------- mangakissa · 2016-11-25 07:30 Create an Array which is similar to your radiobuttons Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i const MyTour : array[0..4] of string = ('one','two','three','four','five'); procedure TForm1.Button1Click(Sender: TObject);begin  if SaveDialog1.Execute then      StringGrid1.SaveToFile(MyTour[RadioGroup1.itemindex]);end;