Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vb.net 选项卡控件的内容是';除非单击,否则无法加载_Vb.net_Winforms_Tabs_Controls - Fatal编程技术网

Vb.net 选项卡控件的内容是';除非单击,否则无法加载

Vb.net 选项卡控件的内容是';除非单击,否则无法加载,vb.net,winforms,tabs,controls,Vb.net,Winforms,Tabs,Controls,我有一个VB应用程序,有8个选项卡 此应用程序可编辑/添加内容并打印报告。第一个选项卡是默认的 但是,我对大多数选项卡都有某些限制,这些选项卡需要作为参数通过报表传递,因此,如果在单击选项卡之前运行报表,它将无法获得值。我试图获取的这些控件只是复选框,运行报告会发送所有False,我知道有选中的控件。我不确定如何在不单击选项卡本身的情况下获得正确的值 下面的代码是我的主窗体的全部代码 Public Sub New(ByVal session As UserSession, ByRef c

我有一个VB应用程序,有8个选项卡

此应用程序可编辑/添加内容并打印报告。第一个选项卡是默认的

但是,我对大多数选项卡都有某些限制,这些选项卡需要作为参数通过报表传递,因此,如果在单击选项卡之前运行报表,它将无法获得值。我试图获取的这些控件只是复选框,运行报告会发送所有False,我知道有选中的控件。我不确定如何在不单击选项卡本身的情况下获得正确的值

下面的代码是我的主窗体的全部代码

    Public Sub New(ByVal session As UserSession, ByRef caller As Form)
    InitializeComponent()
    thisSession = session

    IncidentControl1.FormSession = session
    PersonsControl1.FormSession = session
    VictimControl1.FormSession = session
    VehicleControl1.FormSession = session
    UseOfForceControl1.FormSession = session
    NarrativeControl1.FormSession = session

    callingForm = caller
    blnHome = True
End Sub

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

    Try
        InitializeDataStructures()

        LoadReport()
        CreateDataRelations()
        SetUpTabControls()
        SetupDataBindings()
        SetStatusLabels()
        addHandlers()
        thisSession.sigAdmin

        TabControl1.SelectTab(1) ' these 2 lines fixed my issue
        TabControl1.SelectTab(0)

End Sub

Private Sub SetUpTabControls()
    LocationTab1.SetupTab(subLocationDT, thisSession, thisSession.reportID, dsMain)
    ActorTabv11.SetupTab(dsMain, thisSession)
End Sub
Public Sub SetupTab(ByRef formDataSet As DataSet, ByVal session As UserSession)
    incidentReportDS = formDataSet
    thisSession = session

    thisSession = session
    'incidentReportDS = incidentReportDS
    dataUtil = New DAL.DataUtil

    bcActor = BindingContext(vwActor)


    vwIncidentArrest = Actors(0).IncidentArrest()


    SetupFieldAvailableValues()

    SetUpDataBindings()

    AddEventHandlers()
    bcActor_PositionChanged(Me, EventArgs.Empty)

End Sub
这是我的主窗体中的选项卡

    Public Sub New(ByVal session As UserSession, ByRef caller As Form)
    InitializeComponent()
    thisSession = session

    IncidentControl1.FormSession = session
    PersonsControl1.FormSession = session
    VictimControl1.FormSession = session
    VehicleControl1.FormSession = session
    UseOfForceControl1.FormSession = session
    NarrativeControl1.FormSession = session

    callingForm = caller
    blnHome = True
End Sub

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

    Try
        InitializeDataStructures()

        LoadReport()
        CreateDataRelations()
        SetUpTabControls()
        SetupDataBindings()
        SetStatusLabels()
        addHandlers()
        thisSession.sigAdmin

        TabControl1.SelectTab(1) ' these 2 lines fixed my issue
        TabControl1.SelectTab(0)

End Sub

Private Sub SetUpTabControls()
    LocationTab1.SetupTab(subLocationDT, thisSession, thisSession.reportID, dsMain)
    ActorTabv11.SetupTab(dsMain, thisSession)
End Sub
Public Sub SetupTab(ByRef formDataSet As DataSet, ByVal session As UserSession)
    incidentReportDS = formDataSet
    thisSession = session

    thisSession = session
    'incidentReportDS = incidentReportDS
    dataUtil = New DAL.DataUtil

    bcActor = BindingContext(vwActor)


    vwIncidentArrest = Actors(0).IncidentArrest()


    SetupFieldAvailableValues()

    SetUpDataBindings()

    AddEventHandlers()
    bcActor_PositionChanged(Me, EventArgs.Empty)

End Sub
编辑: 我在主窗体加载的末尾添加了TabControl1.SelectTab()方法来选择我想要的选项卡,然后只选择第一个选项卡,使它们全部加载。

这种行为(问题)是意料之中的。引用

在显示选项卡页之前,不会创建选项卡页中包含的控件,并且在显示选项卡页之前,不会激活这些控件中的任何数据绑定

解决方案


要解决此问题:

我明白了。这是很不幸的,你知道如何解决这个问题吗?如果不看你所有的代码,很难给你一个精确的配方。我通常在构造函数中以编程方式创建所有控件。我发现这篇文章可能有些用处:。实际上,我刚刚实现了该链接中第一个答案的建议。在加载窗体时使每个控件处于活动状态。感谢您的指导,并帮助我解决我的问题@如果你正在使用数据绑定,那么你应该考虑使用数据作为参数的来源。这将避免依赖任何控制。