我用三个控件是edit、button和OpenDialog,我想用BUTTON使OPENDIALOG所指向的某个文件的路径显示在EDIT里面.

解决方案 »

  1.   

    在button.click事件中写如下语句
      Opendialog1.Title := '请选择XXX文件';       
      opendialog1.Filter := 'exe执行文件|*.exe';  
      opendialog1.FileName := 'c:\test\test.exe'; //初始化  if opendialog1.Execute then
         edit1.Text := opendialog1.FileName;
      

  2.   

    function GetNamePath: string;
      

  3.   

    function GetNamePath: string;
      

  4.   

    edit1.text:=ExpandFileName(OpenDialog.filename);
      

  5.   

    如果只是要路径,不要文件名的话,可以再加:edit2.Texe := opendialog1.FileTile;
    edit3.Text := opendialog1.FileName;
    edit1.Text := edit3.Text - edit2.Texe; 
    如果不行的话,可以利用 SelStart 、SelLength 来实现
      

  6.   

    在button1.click(……)中填写以下代码就可以了。
     if opendialog1.Execute then
         edit1.Text := opendialog1.FileName;
      

  7.   

    EXTRACTFILEPATHedit1.text:=EXTRACTFILEPATH(OpenDialog.filename);