在Load事件,VB.NET桌面中控制fLOw

时间:2013-10-16 20:33:46

标签: vb.net visual-studio-2010 visual-studio debugging

我的对话框中有这个代码:

Private Sub DAddSupplier_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    Dim objProveedores As New AR.CMP.ControlCatalogo()
    Dim dvClases, dvEstados As DataView

    dvClases = objProveedores.ListarClasesProveedor()

    If dvClases IsNot Nothing AndAlso dvClases.Count > 0 Then

        For i As Integer = 0 To dvClases.Count
            cmbClase.Items.Add(dvClases(i)("Class"))
        Next

    End If
    'reach until here the debugger 
    dvEstados = objProveedores.ListarEstadosProveedor()

    If dvEstados IsNot Nothing AndAlso dvEstados.Count > 0 Then

        For j As Integer = 0 To dvEstados.Count
            cmbEstado.Items.Add(dvEstados(j)("Name"))
        Next

    End If

End Sub

但只有第二个代码块才会被忽略,除非第一个得到注释,为什么会出现这种行为?

1 个答案:

答案 0 :(得分:0)

只需将它放在initializationComponent调用之后就可以了,它将起作用