异常 - 未将对象引用设置为对象的实例。

时间:2017-07-02 12:10:54

标签: .net exception checkbox nullreferenceexception object-reference

我正在尝试格式化复选框的文本,但我得到'对象引用未设置为对象的实例。'例外。 有什么想法吗?

    Dim i As Decimal = 0
    Dim Cb As CheckBox
    Dim tr As Control
    Dim td As Control
    Dim cont As New Control



    For Each tr In TableSfarimNosafim.Controls
        For Each td In tr.Controls
            For Each cont In td.Controls
                'Cb = DirectCast(cont, CheckBox)
                Cb = TryCast(cont, CheckBox)
                Cb.Text = clsTargumKodim.SfarimNosafim(i)
                i = i + 1
            Next
        Next
    Next

谢谢:)

0 个答案:

没有答案