【问题标题】:TreeView appears as CustomControl - cannot re-cast to TreeViewTreeView 显示为 CustomControl - 无法重新转换为 TreeView
【发布时间】:2014-07-21 12:28:35
【问题描述】:

我有一个表单中的TreeView(特别是Microsoft TreeView Control, version 6.0),虽然它不能很好地与 VBE 的 Intellisense 配合使用,但我可以使用它的所有属性、函数等。

很遗憾,我似乎无法做到这一点:

Dim tvw As TreeView
Set tvw = Me.MyTreeView 'The control on the form

我收到类型不匹配错误。所以我启动了即时窗口并查看了我的表单 TreeView 的类型:

? TypeName(Me.MyTreeView)
CustomControl

看来,无论出于何种原因,VBA 都将我的 TreeView 对象视为 CustomControl 对象。

如何将CustomControl 转换回TreeView(或首先让VBA 将其视为“TreeView”)? VBA 中似乎不存在类型转换(至少,VB 的CType 函数不起作用)。我正在为 TreeView 编写一个包装类,因此仅将其视为 CustomControl 是行不通的,因为我需要访问 Treeview 的事件等。

【问题讨论】:

    标签: vba ms-access casting treeview


    【解决方案1】:

    再深入一点,这个answer on another question 似乎奏效了:

    Dim tvw As TreeView
    Set tvw = Me.MyTreeView.Object
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-04-07
      • 1970-01-01
      • 1970-01-01
      • 2013-11-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多