以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  [求助]粘贴问题  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=109933)

--  作者:积水成渊
--  发布时间:2017/11/23 9:37:00
--  [求助]粘贴问题
现在有个表A: 字段有项目,序号等,现在客户提出这样的需求,当字段序号的内容为1时,字段项目对应的行禁止粘贴,这个需求的代码怎么编写
图片点击可在新窗口打开查看此主题相关图片如下:j9w5uq2ztf$6v}6s(kr(~dg.png
图片点击可在新窗口打开查看

--  作者:有点甜
--  发布时间:2017/11/23 9:52:00
--  

startEdit事件

 

If e.Col.name = "第一列" AndAlso e.Row("第二列") = "1" Then
    If vars("粘贴") = True Then
        e.cancel = True
    End If
End If

 

keyDow事件

 

If e.keycode = keys.V AndAlso e.control = True Then
    vars("粘贴") = True
End If

 

keyUp事件

 

vars("粘贴") = False


--  作者:积水成渊
--  发布时间:2017/11/23 11:09:00
--  
老师,为什么我把表事件换成全局事件,代码的功能就失效了呢:
全局事件代码:StartEdit
Select Case e.Table.DataTable.Name
    Case "啊啊"
    If e.Col.name = "第一列" AndAlso e.Row("第二列") = "1" Then
    If vars("粘贴") = True Then
        e.cancel = True
    End If
End If
End Select
全局事件代码:KeyDown
Select Case e.Table.DataTable.Name
    Case "啊啊"
        If e.keycode = keys.V AndAlso e.control = True Then
            vars("粘贴") = True
        End If
End Select
全局事件代码:KeyUp
Select Case e.Table.DataTable.Name
    Case "啊啊"
vars("粘贴") = False
End Select


--  作者:有点甜
--  发布时间:2017/11/23 11:16:00
--  

全局表事件,你要开启的,比如

 

For Each dt As DataTable In DataTables
    dt.GlobalHandler.StartEdit = True
    dt.GlobalHandler.KeyDown = True
    dt.GlobalHandler.KeyUp = True
Next


--  作者:积水成渊
--  发布时间:2017/11/23 11:33:00
--  
感谢老师