Foxtable(狐表)用户栏目专家坐堂 → MainTable = Tables("合同") 不激活MainTableChanging


  共有2492人关注过本帖树形打印复制链接

主题:MainTable = Tables("合同") 不激活MainTableChanging

帅哥哟,离线,有人找我吗?
有点甜
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2017/11/22 16:51:00 [显示全部帖子]

1、你条件本身就有问题。如果能使用 Tables("合同") ,那么肯定不满足 DataTables.Contains(e.NewTableName)=False

 

2、你可以在事件加入msgbox(123)看是否触发

 

3、只有表格切换的时候才会触发事件,如果你现在就在合同表,肯定不触发。


 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2017/11/22 21:55:00 [显示全部帖子]

全局代码

 

Property MainTable As String

Get

Return foxtable.MainTable.name

End Get

Set  (ByVal value As String)

If Tables.contains(value) Then
    foxtable.MainTable = Tables(value)
Else
    msgbox("不存在表[" & value & "]")
End If
End Set
End Property

 

调用代码

 

MainTable = "表C"

[此贴子已经被作者于2017/11/22 21:56:50编辑过]

 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2017/11/23 16:06:00 [显示全部帖子]

mark,全局代码

 

Public Class myTableCollection
Public Sub new
End Sub

Default Public readonly Property Item(tname As String) As Table
Get
If Foxtable.Tables.Contains(tname) Then
    Return Foxtable.Tables(tname)
Else
    msgbox("测试,不存在表【" & tname & "】")
    Return Nothing
End If
End Get
End Property

End Class

Public mytables = new myTableCollection

readonly Property Tables As myTableCollection
Get
Return mytables
End Get
End Property

 

测试电脑代码

 

msgbox(Tables.Gettype.name)
msgbox(Tables("表B").name)
MainTable = Tables("表B")
MainTable = Tables("表abc")


 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2017/11/23 16:57:00 [显示全部帖子]

完整点改成这样,基本就没问题了。

 

Public Class myTableCollection

Public Sub new
End Sub

Public Function GetEnumerator() As System.Collections.Generic.IEnumerator(Of Table)
Return foxtable.Tables.GetEnumerator
End Function


Default Public readonly Property Item(tname As String) As Table
Get
If Foxtable.Tables.Contains(tname) Then
    Return Foxtable.Tables(tname)
Else
    msgbox("测试,不存在表【" & tname & "】")
    Return Nothing
End If
End Get
End Property

Public readonly Property count() As Integer
Get
Return foxtable.Tables.count
End Get
End Property

Public readonly Property contains(tname As String) As Boolean
Get
Return foxtable.Tables.contains(tname)
End Get
End Property

End Class

Public mytables = new myTableCollection

readonly Property Tables As myTableCollection
Get
Return mytables
End Get
End Property


 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  5楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2018/12/26 17:25:00 [显示全部帖子]

以下是引用affixed在2018/12/26 16:01:00的发言:

结果还是原来的提示内容:不存在名称为"测试"的Table!  而不是"测试,不存在表【测试】"

 

请认认真真看7楼代码,以及调用代码。

 

Public Class myTableCollection

Public Sub new
End Sub

Public Function GetEnumerator() As System.Collections.Generic.IEnumerator(Of Table)
Return foxtable.Tables.GetEnumerator
End Function


Default Public readonly Property Item(tname As String) As Table
Get
If Foxtable.Tables.Contains(tname) Then
    Return Foxtable.Tables(tname)
Else
    msgbox("测试,不存在表【" & tname & "】")
    Return Nothing
End If
End Get
End Property

Public readonly Property count() As Integer
Get
Return foxtable.Tables.count
End Get
End Property

Public readonly Property contains(tname As String) As Boolean
Get
Return foxtable.Tables.contains(tname)
End Get
End Property

End Class

Public mytables = new myTableCollection

readonly Property Tables As myTableCollection
Get
Return mytables
End Get
End Property

 

-----------------------

 

msgbox(Tables.Gettype.name)
msgbox(Tables("表B").name)
MainTable = Tables("表B")
MainTable = Tables("表abc")

 

 


 回到顶部