点一个按钮,想打开个文件在CHART上,我需要打开2种文件,一个是DAT,一个是BMP,但是我的程序只能打开BMP,找不到DAT啊 ,不知道怎么回事,希望大家能帮我看看,谢谢
procedure TMainForm.Action1Execute(Sender: TObject);var
  f:TextFile;
  str:string;
begin
  opendialog1.Filter:='datÎļþ(*.dat) |*.dat |bmpÎļþ(*.bmp) |*.bmp';
  opendialog1.Execute;
  str:=copy(opendialog1.FileName,length(opendialog1.FileName)-2,3);
  if str='dat' then
  begin
    Assignfile(f,OpenDialog1.FileName);
    Reset(f);
    try
      while not Eof(f) do
      begin
        Readln(f,Rx,Ry );
        PointsA.AddXY(Rx, Ry);
      end;
    finally
      closefile(f);
    end;
  end;
  if str='bmp' then
  begin
      PicFileName := opendialog1.FileName;
      cht1.BackImage.LoadFromFile(PicFileName);
      stat1.Panels[0].Text := PicFileName;
  end;
end;

解决方案 »

  1.   

    现在可以看到DAT文件可,但是打不开啊
      

  2.   

    你的dat格式对吗?
    你可以在 Readln(f,Rx,Ry ); 设置端点看看
      

  3.   

    可以opendialog里filter里设置可以打开的类型
      

  4.   

    非常感谢你,我知道我错哪了,我在程序里动态调用了Fliter,在静态的属性里我也设置了,导致2者的冲突,去掉一个就好了,谢谢,祝你一切顺利