码迷,mamicode.com
首页 > 其他好文 > 详细

delphi 获取 TreeView选中的文件路径

时间:2014-08-01 12:54:11      阅读:205      评论:0      收藏:0      [点我收藏+]

标签:blog   http   color   io   文件   for   2014   cti   


bubuko.com,布布扣
 
//获取 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 获取 TreeView选中的文件路径,布布扣,bubuko.com

    delphi 获取 TreeView选中的文件路径

    标签:blog   http   color   io   文件   for   2014   cti   

    原文地址:http://www.cnblogs.com/xe2011/p/3884438.html

    (0)
    (0)
       
    举报
    评论 一句话评论(0
    登录后才能评论!
    © 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
    迷上了代码!