当我的窗体隐藏并重新加载从另一种形式是不执行code在Load事件我的、窗体、加载、形式

由网友(白衣枕边书)分享简介:所以,我有一个程序从中我从一个DataGrid检索数据和一个经过电网之一,但,当我关闭窗体使用 Me.Hide 和再次使用重载从另一种形式 frmQuiz.Show 不执行code在frmQuiz形式的Load事件,因此它结束了一个记录我留下的最后一次。这里是code从该表 - Load事件私人小组frmQuiz_L...

所以,我有一个程序从中我从一个DataGrid检索数据和一个经过电网之一,但,当我关闭窗体使用 Me.Hide 和再次使用重载从另一种形式 frmQuiz.Show 不执行code在frmQuiz形式的Load事件,因此它结束了一个记录我留下的最后一次。这里是code从该表 - Load事件

 私人小组frmQuiz_Load(发件人为System.Object的,E作为System.EventArgs)把手MyBase.Load
    跟踪= 0'来跟踪记录从数据网格中检索,在这种情况下,第一

    'TODO:这行code加载数据到CompLitDataSet.tblQuestions'表。您可以移动,或将其删除,因为需要的。
    Me.TblQuestionsTableAdapter.Fill(Me.CompLitDataSet.tblQuestions)
    hideGrid()
    dgData.DataSource = TblQuestionsTableAdapter.GetAllUnsorted
    在中心屏幕Me.StartPosition = FormStartPosition.CenterParent'负载形式
    REDIM答案(TblQuestionsBindingSource.Count)

    lblQuestion.Text =
    lblQuestionNumber.Text =
    PictureBox1.Visible = FALSE
    radA.Checked =假
    radB.Checked =假
    radC.Checked =假
    radD.Checked =假

    viewQuestions(0)显示第一个问题

结束小组
 

解决方案

Me.Hide 只是让的形式无形的,但它仍然加载到内存中,并通过$ C访问$ C。

Me.Close 从内存中卸载窗体,而不是通过code再访问。

So i have a program from which I am retrieving data from a datagrid and going through the grid one by one but when i close the form using theMe.Hide and the reload it again from another form using frmQuiz.Show it does not execute the code in the Load event of the frmQuiz form and as a result it ends up on a record I left on from last time. Here is code from the Load event of the form

VSCode设置类似Webstorm那样可以用本地局域网IP地址访问自己开发的测试项目,vs code 前端如何以服务器模式打开 强哥 CSDN博客 vscode局域网

   Private Sub frmQuiz_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
    tracker = 0 'to keep track of which record to retrieve from datagrid,in this case the first

    'TODO: This line of code loads data into the 'CompLitDataSet.tblQuestions' table. You can move, or remove it, as needed.
    Me.TblQuestionsTableAdapter.Fill(Me.CompLitDataSet.tblQuestions)
    hideGrid()
    dgData.DataSource = TblQuestionsTableAdapter.GetAllUnsorted
    Me.StartPosition = FormStartPosition.CenterParent 'load form at center screen
    ReDim answers(TblQuestionsBindingSource.Count)

    lblQuestion.Text = ""
    lblQuestionNumber.Text = ""
    PictureBox1.Visible = False
    radA.Checked = False
    radB.Checked = False
    radC.Checked = False
    radD.Checked = False

    viewQuestions(0) 'show first questions

End Sub

解决方案

Me.Hide just makes the form invisible, it is still loaded in memory and accessible via code.

Me.Close unloads the form from memory and is not accessible via code anymore.

阅读全文

相关推荐

最新文章