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 高亮选中memo某一行

Delphi 获取网络图片在webbrowser显示 android/osx/ios/win的最佳方式

Delphi ^ 符号的特殊用法

Delphi 在窗体上创建自己的光标并输入文字

Delphi 随意将函数执行权限提高到ring0源代码

Delphi 根据进程名称获取进程号

Delphi格式化函数format、formatdatetime和formatfloat

Delphi之猥琐的webserver实现

Delphi 标头控件(theadercontrol)中的显示复选框

Delphi 判断两个时间差是否在一个指定范围内

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



打赏

取消

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

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

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

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

评论

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