设为首页收藏本站Access中国

Office中国论坛/Access中国论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

返回列表 发新帖
查看: 3054|回复: 2
打印 上一主题 下一主题

[ActiveX] [经验]imagelist treeview里的KEY是区分大小写的

[复制链接]

点击这里给我发消息

跳转到指定楼层
1#
发表于 2015-2-15 15:36:05 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

帮一个网友调试程序。发现一个问题,以前也遇到过,发现不少人遇到,所以分享一下
就是 imagelist treeview里的KEY是区分大小写的

如果下面的代码中这样写,后面treeview添加图标时 这句:
Set node1 = TreeView1.Nodes.Add(, , "根1", "工厂1", "K1", "K2")
提示运行时错误 35601 未发现元素
img.ListImages.Add 1, "k1, LoadPicture(CurrentProject.Path & "\jia.ico")
img.ListImages.Add 2, "k2", LoadPicture(CurrentProject.Path & "\jian.ico")


改成 大写
img.ListImages.Add 1, "K1", LoadPicture(CurrentProject.Path & "\jia.ico")
    img.ListImages.Add 2, "K2", LoadPicture(CurrentProject.Path & "\jian.ico")

就正常了

完整代码如下:

Private Sub Form_Load()
    Dim img As ImageList
    Dim node1 As Node

    Set img = Me.ImageList1.Object
    img.ListImages.Add 1, "K1", LoadPicture(CurrentProject.Path & "\jia.ico")
    img.ListImages.Add 2, "K2", LoadPicture(CurrentProject.Path & "\jian.ico")
    Set TreeView1.ImageList = img


    Set node1 = TreeView1.Nodes.Add(, , "根1", "工厂1", "K1", "K2")
    Set node1 = TreeView1.Nodes.Add(, , "根2", "工厂2", "K1", "K2")

    Set node1 = TreeView1.Nodes.Add("根1", tvwChild, "树杈1", "1车间", "K1", "K2")
    Set node1 = TreeView1.Nodes.Add("根2", tvwChild, "树杈21", "1车间", "K1", "K2")
    Set node1 = TreeView1.Nodes.Add("根1", tvwChild, "树杈2", "2车间", "K1", "K2")
    Set node1 = TreeView1.Nodes.Add("根2", tvwChild, "树杈22", "总装车间", "K1", "K2")

    Set node1 = TreeView1.Nodes.Add("树杈1", tvwChild, "树枝1", "手机", "K1", "K2")
    Set node1 = TreeView1.Nodes.Add("树杈21", tvwChild, "树枝21", "计算机配件", "K1", "K2")
    Set node1 = TreeView1.Nodes.Add("树杈1", tvwChild, "树枝2", "电话", "K1", "K2")
    Set node1 = TreeView1.Nodes.Add("树杈2", tvwChild, "树枝3", "手视机", "K1", "K2")
    Set node1 = TreeView1.Nodes.Add("树杈2", tvwChild, "树枝4", "洗衣机", "K1", "K2")
    Set node1 = TreeView1.Nodes.Add("树杈2", tvwChild, "树枝5", "电冰箱", "K1", "K2")
    Set node1 = TreeView1.Nodes.Add("树杈22", tvwChild, "树枝221", "显示器", "K1", "K2")
    Set node1 = TreeView1.Nodes.Add("树杈22", tvwChild, "树枝222", "主机", "K1", "K2")

    node1.Sorted = True
    TreeView1.Style = 5
    TreeView1.Font = "宋体"
    TreeView1.Appearance = 1
    TreeView1.Nodes(1).Expanded = True
End Sub

分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享分享 分享淘帖 订阅订阅

点击这里给我发消息

2#
发表于 2015-2-15 22:06:53 | 只看该作者
确实如此,我就曾因为这个问题折腾了半天,还以为是树控件出了问题
3#
发表于 2015-4-14 22:09:50 | 只看该作者
不错
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|站长邮箱|小黑屋|手机版|Office中国/Access中国 ( 粤ICP备10043721号-1 )  

GMT+8, 2024-11-25 07:34 , Processed in 0.095675 second(s), 31 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表