以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  窗口按钮Enabled属性无效  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=154230)

--  作者:andy-1024
--  发布时间:2020/9/8 17:31:00
--  窗口按钮Enabled属性无效

老师好,我的窗口中有一个按钮,我需要实现的功能是:点击按钮后,本按钮先禁用,然后执行后续代码。

但是现在有一个问题,点击这个有问题的按钮以后,它自身没有禁用,其余所有代码都正常运行了,后续代码中涉及的其它按钮的禁用也都正常。

然后第二次点击这个问题按钮后,它本身才被禁用,后续代码也正常运行。

 

我尝试过两种不同的代码书写:

e.Form.Controls("btnAdd").Enabled = False

e.Sender.Enabled = False
结果都是一样的。

 

然而窗口中的其它按钮都正常,只有这一个例外,不知道是怎么回事。

 


--  作者:有点蓝
--  发布时间:2020/9/8 17:35:00
--  
按钮完整代码
--  作者:andy-1024
--  发布时间:2020/9/8 17:38:00
--  

Dim t As WinForm.Table = e.Form.Controls("Table1")
Dim LId As WinForm.Label = e.Form.Controls("LId")
Dim CbFilter As WinForm.ComboBox = e.Form.Controls("CbFilter")
Dim TFilter As WinForm.TextBox = e.Form.Controls("TFilter")
Dim btnSearch As WinForm.Button = e.Form.Controls("BtnSearch")
Dim btnPrint As WinForm.Button = e.Form.Controls("btnPrint")
Dim CbType As WinForm.ComboBox = e.Form.Controls("CbType")
Dim TCode As WinForm.TextBox = e.Form.Controls("TCode")
Dim TName As WinForm.TextBox = e.Form.Controls("TName")
Dim TBox As WinForm.TextBox = e.Form.Controls("TBox")
Dim TAdd As WinForm.TextBox = e.Form.Controls("TAdd")
Dim TCP As WinForm.TextBox = e.Form.Controls("TCP")
Dim TCell As WinForm.TextBox = e.Form.Controls("TCell")
Dim TTel As WinForm.TextBox = e.Form.Controls("TTel")
Dim TFax As WinForm.TextBox = e.Form.Controls("TFax")
Dim TEM As WinForm.TextBox = e.Form.Controls("TEM")
Dim TWC As WinForm.TextBox = e.Form.Controls("TWC")
Dim TWA As WinForm.TextBox = e.Form.Controls("TWA")
Dim TMemo As WinForm.TextBox = e.Form.Controls("TMemo")

 

CbFilter.Enabled = False
CbFilter.Value = Nothing
TFilter.Enabled = False
TFilter.Value = Nothing
btnSearch.Enabled = False
btnPrint.Enabled = False
t.Table.Filter = "[_Identify] Is Null"

 

e.Form.Controls("btnAdd").Enabled = False        \'问题代码行
e.Form.Controls("btnMod").Enabled = False
e.Form.Controls("btnSave").Enabled = False
e.Form.Controls("btnCancel").Enabled = True

LId.Text = Vars("ShopCode") & Vars("TermiCode")
Dim nr As DataRow = t.Table.DataTable.SQLAddNew()
nr("sys_ID") = LId.Text
nr.Save()

CbType.Enabled = True
CbType.Value = Nothing
TCode.Value = Nothing
TName.Enabled = True
TName.Value = Nothing
TBox.Enabled = True
TBox.Value = Nothing
TAdd.Enabled = True
TAdd.Value = Nothing
TCP.Enabled = True
TCP.Value = Nothing
TCell.Enabled = True
TCell.Value = Nothing
TTel.Enabled = True
TTel.Value = Nothing
TFax.Enabled = True
TFax.Value = Nothing
TEM.Enabled = True
TEM.Value = Nothing
TWC.Enabled = True
TWC.Value = Nothing
TWA.Enabled = True
TWA.Value = Nothing
TMemo.Enabled = True
TMemo.Value = Nothing


--  作者:有点蓝
--  发布时间:2020/9/8 20:14:00
--  
估计是和其它控件的代码有冲突,还有什么控件的事件会设置e.Form.Controls("btnAdd").Enabled属性的?
--  作者:andy-1024
--  发布时间:2020/9/8 21:06:00
--  

是的,我找到问题了,原因是窗口中的一个表的事件代码中的一行代码。

谢谢老师提醒!