以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  关于afterload事件的一个问题  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=127114)

--  作者:huangxueyao
--  发布时间:2018/11/6 9:13:00
--  关于afterload事件的一个问题
在窗体的afterload,我加了一段代码用于改变某个控件的只读属性
但发现没有起作用。

是因为afterload事件执行完之前,控件还没加载么?

--  作者:y2287958
--  发布时间:2018/11/6 9:26:00
--  
afterload控件已加载
上传代码

--  作者:huangxueyao
--  发布时间:2018/11/6 9:29:00
--  
For Each c As object In e.Form.Controls
    Dim st2 As String = c.BindingField
    If st2 IsNot Nothing AndAlso st2.length > 0 Then
            c.ReadOnly = BooleanEnum.true
    End If
Next

--  作者:有点甜
--  发布时间:2018/11/6 9:50:00
--  

1、我这样测试没问题

 

For Each c As object In e.Form.Controls
   
    c.ReadOnly = BooleanEnum.True
   
Next

 

2、你加入msgbox测试一下,如

 

For Each c As object In e.Form.Controls
    Dim st2 As String = c.BindingField
msgbox(st2 & " " & st2 <> Nothing)
    If st2 <> Nothing Then
msgbox(c.name)
            c.ReadOnly = BooleanEnum.true
    End If
Next