请教Treeview控件的用法

gyong518 2004-03-30 07:07:46
假如Treeview控件编程时有三级子节点,怎样用Treeview控件显示ImageList控件的图片
...全文
25 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
pcwak 2004-03-30
  • 打赏
  • 举报
回复
http://www.access-cn.com/Article_Show.asp?ArticleID=310
goodmanh 2004-03-30
  • 打赏
  • 举报
回复
Dim ndd As Node

'语法object.Add(relative, relationship, key, text, image, selectedimage)

'image就是当前imagelist中的图片编号,selectedimage是节点被选中的图片编号

Set ndd = TreeView1.Nodes.Add(, , "Cust", "Customer", 1, 2)


Set ndd = TreeView1.Nodes.Add("Cust", tvwChild, "Aust", "Australia", 1, 2)
Set ndd = TreeView1.Nodes.Add("Cust", tvwChild, "Eng", "England", 1, 2)
Set ndd = TreeView1.Nodes.Add("Aust", tvwChild, "Adam", "Adam", 1, 2)
Set ndd = TreeView1.Nodes.Add("Aust", tvwChild, "Joe", "Joe", 1, 2)
Set ndd = TreeView1.Nodes.Add("Aust", tvwChild, "Tow", "Tom", 1, 2)
Set ndd = TreeView1.Nodes.Add("Eng", tvwChild, "Andr", "Andrew", 1, 2)
Set ndd = TreeView1.Nodes.Add("Eng", tvwChild, "Jac", "Jacobo", 1, 2)
Set ndd = TreeView1.Nodes.Add(, , "Asi", "Asia", 1, 2)
Set ndd = TreeView1.Nodes.Add("Asi", tvwChild, "Chi", "China", 1, 2)
Set ndd = TreeView1.Nodes.Add("Asi", tvwChild, "Jan", "Japan", 1, 2)
Set ndd = TreeView1.Nodes.Add(, , "A", "AA", 1, 2)
Set ndd = TreeView1.Nodes.Add("A", tvwChild, "B", "BB", 1, 2)
Set ndd = TreeView1.Nodes.Add("A", tvwChild, "C", "CC", 1, 2)
Set ndd = TreeView1.Nodes.Add("C", tvwChild, "E", "EE", 1, 2)
Set ndd = TreeView1.Nodes.Add("A", tvwChild, "F", "FF", 1, 2)
TreeView1.LineStyle = tvwRootLines
TreeView1.Checkboxes = True
TreeView1.Nodes(1).Checked = True
TreeView1.Nodes(2).ForeColor = vbRed

ndd.EnsureVisible

End Sub
daisy8675 2004-03-30
  • 打赏
  • 举报
回复
1、設置對應的image
frmPhoneBook.treComtel.ImageList = frmPhoneBook.imgCust
2.找到圖片對應的key,比如我的下面就是1
Set NodeList = .Add(, , "Root", "所有人員", 1)
如果隻是圖片就是這麼設置的

'TreeView 引用方法
'nodes.add 親子, 親子關係,索引鍵,文字,示意圖,被選取的圖示
一切就是依附上面這話

1,216

社区成员

发帖
与我相关
我的任务
社区描述
VB 数据库(包含打印,安装,报表)
社区管理员
  • 数据库(包含打印,安装,报表)社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧