以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  beforecolse中的cancel = true 不起作用?  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=158154)

--  作者:tld
--  发布时间:2020/11/10 5:35:00
--  beforecolse中的cancel = true 不起作用?
老师,我在窗口的beforeclose事件中有如下代码:
For Each dr As DataRow In DataTables(e.Form.name & "_table1").dataRows
    If dr.RowState <> DataRowstate.unchanged Then
        Dim Result As DialogResult
        Result = MessageBox.Show("上表中有未保存的行 , 请确认是否需要处理 ?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
        If Result = DialogResult.Yes Then
            e.Cancel = True
            Return
        End If
    End If
Next

执行上述代码,点击 yes 后,窗口依然关闭,不知道什么原因?请指点。谢谢!

--  作者:有点蓝
--  发布时间:2020/11/10 9:08:00
--  
参考:http://www.foxtable.com/webhelp/topics/0387.htm

If DataTables(e.Form.name & "_table1").HasChanges Then
    If 
MessageBox.Show("产品表已经被修改,是否保存?""提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = DialogResult.Yes Then
      
e.Cancel = True
    End
 If 
End
 
If

--  作者:tld
--  发布时间:2020/11/10 10:24:00
--  
老师,我不理解的是,点击了yes,就必须执行e.cancel = true , 但是窗口还是退出了,return 也没有起到作用 。
--  作者:有点蓝
--  发布时间:2020/11/10 10:27:00
--  
这个是主窗口类型?如果表A有2个主窗口,打开主窗口1,然后打开主窗口2,这时主窗口1会自动关闭,这种情况主窗口1不会触发beforecolse
--  作者:tld
--  发布时间:2020/11/10 10:38:00
--  
老师,是有两个主窗口,但是,我既然能够点击 yes,说明已经进入到 beforecolse 事件中了,执行了这里的代码啊 。


--  作者:有点蓝
--  发布时间:2020/11/10 10:42:00
--  
e.Cancel = True不会有效
--  作者:有点蓝
--  发布时间:2020/11/10 10:42:00
--  
因为一个表格的主窗口只能同时显示一个