以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  清除所有控件内容  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=102321)

--  作者:良才
--  发布时间:2017/6/17 11:38:00
--  清除所有控件内容
控件有三种类型;DropDownBox、ComboBox、TextBox
在”学生姓名“控件 TextChanged 清除“学生姓名”以外控件内容。请老师指点,谢谢!
If winform.DropDownBox <> e.Form.Controls("学生姓名") Then
    For Each c As WinForm.Control In e.Form.Controls
        If Typeof c Is winform.TextBox OrElse TypeOf c Is winform.Combobox OrElse TypeOf c Is winform.DropDownBox Then
            Dim t As WinForm.TextBox = c
            Dim t1 As WinForm.Combobox = c
            Dim t2 As WinForm.DropDownBox = c
            t.Value = Nothing
            t1.Value = Nothing
            t2.Value = Nothing
        End If
    Next
End If
[此贴子已经被作者于2017/6/17 11:40:40编辑过]

--  作者:有点蓝
--  发布时间:2017/6/17 11:42:00
--  
For Each c As WinForm.Control In e.Form.Controls
    If Typeof c Is winform.TextBox OrElse TypeOf c Is winform.Combobox Then
        If c.Name <> e.sender.name
            c.Value = Nothing
        End If
    End If
Next


--  作者:良才
--  发布时间:2017/6/17 12:08:00
--  
错误提示 Value不是winform.Combobox的成员
c.Value = Nothing

--  作者:有点蓝
--  发布时间:2017/6/17 14:10:00
--  
For Each c As object In e.Form.Controls
    If Typeof c Is winform.TextBox OrElse TypeOf c Is winform.Combobox Then
        If c.Name <> e.sender.name
            c.Value = Nothing
        End If
    End If
Next

--  作者:Liangcai
--  发布时间:2017/6/23 10:19:00
--  
谢谢