delphi 获取 TreeView选中的文件路径


本文整理自网络,侵删。

 

 

 //获取 TreeView选中的文件路径

 

unit Unit1;

 

interface

 

uses

  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

  Dialogs, StdCtrls, ComCtrls;

 

type

  TForm1 = class(TForm)

    TreeView1: TTreeView;

    ListView1: TListView;

    RichEdit1: TRichEdit;

    procedure TreeView1Click(Sender: TObject);

  private

    { Private declarations }

  public

    { Public declarations }

  end;

 

var

  Form1: TForm1;

 

implementation

 

{$R *.dfm}

//------------------------------------------------------------------------------

function Get_node_path(node: TTreenode): string;

var

  path: string;

  TreeNode: ttreenode;

begin

  path := node.text;

  TreeNode := node.parent;

  while TreeNode <> nil do

  begin

    path := TreeNode.text + '\' + path;

    TreeNode := TreeNode.parent;

  end;

  Result := path;

end;

//------------------------------------------------------------------------------

procedure TForm1.TreeView1Click(Sender: TObject);

var

    node:TTreeNode;

begin

    node:=TreeView1.Selected;

    Caption:=Get_node_path(Node);

end;

 

 

 

end.


相关阅读 >>

Delphi 如何识别应用程序没有响应

两种方法用Delphi实现域名转ip地址---用nmhttp控件和winsock

高手谈做程序员的8大基本原则

Delphi formatdatetime 显示日期时间

Delphi lastdelimiter:在字符串中查找选定的字符最后出现的位置

Delphi中用ado连接加密access数据库

Delphi tidhttpserver开发http服务端外网无法访问

Delphi实现线程池组件(完整源码)

Delphi xe5 将Delphi code从winos 迁移到ios与android

Delphi 18位身份证号码的校验

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...