guys!
I have this txt file and I want to load the content into a stringgrid. Here's my code :
procedure PopulateStringGrid(Grid: TStringGrid; const FileName: string);
var
TextFile, Line: TStringList;
Row, col: Integer;
begin
Grid.RowCount := 0;//clear any previous data
TextFile := TStringList.Create;
try
Line := TStringList.Create;
try
Line.Delimiter := ' ';
TextFile.LoadFromFile(FileName);
Grid.RowCount := TextFile.Count;
for Row := 0 to TextFile.Count-1 do
begin
Line.DelimitedText := TextFile[Row];
for Col := 0 to Grid.ColCount-1 do
if Col<Line.Count then
Grid.Cells[Col, Row] := Line[Col]
else
Grid.Cells[Col, Row] := '0';
end;
finally
Line.Free;
end;
finally
TextFile.Free;
end;
end;
procedure TForm5.sButton1Click(Sender: TObject);
var filename1:string;
begin
if opendialog1.Execute then
begin
sedit1.Text:=opendialog1.FileName;
filename1:=sedit1.Text;
PopulateStringGrid(StringGrid1, FileName1);
showmessage(filename1);
end
else showmessage('file failed to load');
end;
It works nicely, but the data is too big so I want to use data I need. I need to get data in date range.
here's the pic to explain :
I want to only show the data in range of dates I select in dateedit at top. Any idea how to do that? Thank you in advance! I'm using delphi 7 for this.