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 leftstr 返回字符串左边指定个数的新字符(串)

Delphi idhttp用法详解

Delphi四舍五入问题解决

Delphi adoquery连接数据库的查询、插入、删除、修改

Delphi post数据与对应的接收方式

Delphi http协议验证访问datasnap rest 服务器

Delphi 字串转16进制

Delphi fdconnection1 获取数据库总记录数

Delphi 访问https图片

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



打赏

取消

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

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

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

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

评论

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