本例效果图:

源码:


unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ComCtrls, StdCtrls; type
  TForm1 = class(TForm)
    TreeView1: TTreeView;
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    Button4: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure Button4Click(Sender: TObject);
  end; var
  Form1: TForm1; implementation {$R *.dfm} var
  i: Integer; {这四个按钮的功能是一模一样的}
procedure TForm1.Button1Click(Sender: TObject);
begin
  Self.Text := TreeView1.Items.Item[i].Text;
  if i < TreeView1.Items.Count- then Inc(i) else i := ;   TreeView1.SetFocus;
  TreeView1.Select(TreeView1.Items.Item[i]);
end; {TreeView1.Items.Item[i] 是默认属性, 可以简写为: TreeView1.Items[i]}
procedure TForm1.Button2Click(Sender: TObject);
begin
  Text := TreeView1.Items[i].Text;
  if i < TreeView1.Items.Count- then Inc(i) else i := ;   TreeView1.SetFocus;
  TreeView1.Select(TreeView1.Items[i]);
end; {每个元素都是 TTreeNode 类型的}
procedure TForm1.Button3Click(Sender: TObject);
var
  node: TTreeNode;
begin
  node := TreeView1.Items[i];
  Text := node.Text;
  if i < TreeView1.Items.Count- then Inc(i) else i := ;   TreeView1.SetFocus;
  TreeView1.Select(node);
end; {尽量使用 TTreeNodes 与 TTreeNode}
procedure TForm1.Button4Click(Sender: TObject);
var
  Nodes: TTreeNodes;
  node: TTreeNode;
begin
  Nodes := TreeView1.Items;
  node := Nodes[i];
  Text := node.Text;
  if i < Nodes.Count- then Inc(i) else i := ;   TreeView1.SetFocus;
  TreeView1.Select(node);
end; end.

学习 TTreeView [2] - Items.Item[i]、Items[i]、.Text、SetFocus(设置焦点)、Select(选择)的更多相关文章

  1. 学习 TTreeView [1] - TTreeNodes、TTreeNode 与 Items、Items.Count、Items.Clear

    填写 TTreeView 的内容一般是这样开始的(下图), 不过我觉得最好习惯用动态建立. 打个比方: 譬如 TreeView 是一个军营的"营部"! 这里会有营长.连长.排长.班 ...

  2. 在angular中使用ng-repeat时数组中有重复元素,要用item in items track by $index

    在angular中使用ng-repeat时数组中有重复元素,要用item in items track by $index,不然会报错 <div class="" ng-in ...

  3. 学习 TTreeView [3] - Add、AddChild、AddFirst、AddChildFirst、Parent

    本例效果图: unit Unit1; interface uses   Windows, Messages, SysUtils, Variants, Classes, Graphics, Contro ...

  4. [Python 学习]2.5版yield之学习心得 - limodou的学习记录 - limodou是一个程序员,他关心的焦点是Python, DocBook, Open Source …

    [Python 学习]2.5版yield之学习心得 - limodou的学习记录 - limodou是一个程序员,他关心的焦点是Python, DocBook, Open Source - [Pyth ...

  5. go语言,golang学习笔记3 用命令下载框架报错问题解决 设置环境变量

    go语言,golang学习笔记3 用命令下载框架报错问题解决 设置环境变量 下载安装:go get github.com/astaxie/beego 首页 - beego: 简约 & 强大并存 ...

  6. 学习 TTreeView [16] - 给 TTreeView 添加复选框 (回复 "丁永其" 的问题)

    问题来源: http://www.cnblogs.com/del/archive/2008/05/15/1114450.html#1199402 本例效果图: unit Unit1; interfac ...

  7. 学习 TTreeView [15] - 连接数据库 (作为给 "丁永其" 和 "DELPHI万岁" 两位朋友的回复)

    本例效果图: unit Unit1; interface uses   Windows, Messages, SysUtils, Variants, Classes, Graphics, Contro ...

  8. Editor Scripting学习笔记之Menu Item

    主要用到: MenuItem属性 MenuCommand参数 可能用到: EditorApplication类 Selection类 GameObjectUtility类 FileUtil类 Undo ...

  9. iOS 学习 - 20 UICollectionView 移动 Item ,类似背包

    有100个 item,数据源只有20个,只能在 20 个之间移动,防止 item 复用,出现 bug 方法一:苹果自带 //UICollectionViewDataSource- (BOOL)coll ...

随机推荐

  1. TODO Android +jacoco的增量覆盖率测试和一些概念

    查了下资料,工具要用mac开发,,,,陷入窘境,正在寻找替代方案. Android中的jacoco只支持offline模式,spring支持on-the-fly(在加载class文件进行,运用java ...

  2. machine learning(9) -- classification:Decision boundary

    machine learning(9) -- classification:Decision boundary 上图的decision boundary是一条直线,是属于预测函数的一个属性(当参数已经 ...

  3. 22 Jquery 事件

    一.概述: 当用户与浏览器进行交互时这些方法被用于注册行为生效, 并进一步处理这些注册行为. 二.绑定事件处理器 .bind() ..unbind():为一个元素绑定一个事件处理程序.3.0版本已经弃 ...

  4. 进程间的通信----队列queue

    import multiprocessing def download_from_web(q): """下载数据""" # 模拟下载数据 d ...

  5. Django REST framework+Vue 打造生鲜电商项目(笔记六)

    (部分代码来自https://www.cnblogs.com/derek1184405959/p/8836205.html) 九.个人中心功能开发 1.drf的api文档自动生成 (1) url #d ...

  6. Elasticsearch原理讲透

    小史是一个非科班的程序员,虽然学的是电子专业,但是通过自己的努力成功通过了面试,现在要开始迎接新生活了. 随着央视诗词大会的热播,小史开始对诗词感兴趣,最喜欢的就是飞花令的环节. 但是由于小史很久没有 ...

  7. Greenplum 调优--VACUUM系统表

    Greenplum 调优--VACUUM系统表 1.VACUUM系统表原因 Greenplum是基于MVCC版本控制的,所有的delete并没有删除数据,而是将这一行数据标记为删除, 而且update ...

  8. umediter实现粘贴word图片

    图片的复制无非有两种方法,一种是图片直接上传到服务器,另外一种转换成二进制流的base64码目前限chrome浏览器使用首先以um-editor的二进制流保存为例:打开umeditor.js,找到UM ...

  9. 【概率论】4-7:条件期望(Conditional Expectation)

    title: [概率论]4-7:条件期望(Conditional Expectation) categories: - Mathematic - Probability keywords: - Exp ...

  10. CentOS7安装Airflow

    实验环境: centos7python3.6 安装配置: 1.看看是否有gcc,没有的话需要进行安装: yum install gcc  (后续安装airflow如果不成功,可以再次执行,它会更新包) ...