Foxtable(狐表)用户栏目专家坐堂 → 克隆行和DataColChanging事件冲突


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

主题:克隆行和DataColChanging事件冲突

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


加好友 发短信
等级:小狐 帖子:341 积分:2864 威望:0 精华:0 注册:2023/6/7 16:07:00
克隆行和DataColChanging事件冲突  发帖心情 Post By:2023/7/18 9:56:00 [显示全部帖子]

窗口 按钮 克隆行 提示MessageBox 提示iD已经存在,数据可以正确写入

表DataColChanging   ID自动+1,如果id重复提示 MessageBox.Show ("iD已经存在", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information)


我的需求是:克隆行的时候,不触发表DataColChanging 事件,或者其他解决方案

克隆行参考
http://www.foxtable.com/bbs/dispbbs.asp?BoardID=2&ID=91474


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


加好友 发短信
等级:小狐 帖子:341 积分:2864 威望:0 精华:0 注册:2023/6/7 16:07:00
  发帖心情 Post By:2023/7/18 10:11:00 [显示全部帖子]

'窗口 按钮单击事件
Dim val As Integer 
val = DataTables("表").SQLCompute("max(ID)") + 1
'当前行最大值
Dim max As Integer = DataTables("表").Compute("max(ID)") + 1
Dim valmax As Integer
If val > max Then
    valmax = val
Else
    valmax = max
End If
Dim r As Row = Tables("表").Current
Dim dnew As Row = Tables("表").AddNew
Dim name As String = r("ID") 
For Each c As Col In Tables("表").Cols
    If c.Name = "ID" Then
'        MessageBox.show(valmax)
        dnew(c.Name) = valmax
    ElseIf c.Name = "条件" Then
         dnew(c.Name) = Nothing
    ElseIf c.Name <> "_Identify" Then
        dnew(c.Name) = r(c.Name)
    End If
Next






'DataColChanging事件

Select Case e.DataCol.Name
    Case "ID"
        If e.NewValue IsNot Nothing Then
            Dim dr As DataRow = e.DataTable.Find("id = '" & e.NewValue & "' ")
            If dr IsNot Nothing Then
                StatusBar.Message1 = "此iD已经存在"
                e.Cancel = True
            End If 
        End If

        
End Select


 回到顶部