【问题标题】:Child Form not refreshing when i try to start the app from MDI form?当我尝试从 MDI 表单启动应用程序时,子表单不刷新?
【发布时间】:2010-12-01 22:23:35
【问题描述】:


我的应用中有 MDI 表单和子表单。
这是我的情况...

主表格:MDI表格
注册表格:MDI 表格的子表格
设计表单:当我们单击注册表单上的一个按钮时将打开另一个表单。

现在如果我尝试从 Desig 表​​单刷新注册表单组合框的项目,那么它不会刷新。即我在注册表单的组合框中看不到我的新项目。

现在,当我尝试直接从注册表单启动我的应用程序时,相同的代码可以完美运行,但当我尝试从 MDI 表单启动应用程序时,相同的代码没有运行。

这是我的代码。
MDI 表格:

Dim regform As New Register
StatusLabel.Text = "Opening Workman Registration"
regform.MdiParent = Me
regform.Show()
StatusLabel.Text = "Workman Registration"
regform.concombo.Focus()

注册表:

 Public Sub refreshCombo()
    desigcombo.Items.Clear()
    sitecombo.Items.Clear()

    addDesCombo() ' method which will loads all new data from database 

    desigcombo.Text = designame ' the string variable (designame)


End Sub

设计表格

Register.refreshCombo() ' will run when we will click on one button.

当我们使用 MDI 表单 - 子表单时,他们有什么需要记住的吗?

【问题讨论】:

    标签: vb.net mdichild


    【解决方案1】:

    当您从 Desig 刷新 Register 时,它会在您从 Register 启动应用程序时起作用,因为只有一个 Register 表单并且 VB 会自动将其视为表单的一个实例。

    当注册表单是子表单时,需要使用表单的实例而不是类名,比如MainForm.ActiveMdiChild.refreshCombo()

    【讨论】:

    • 只是一个变化......没有名为“ActiveMdiChild”的方法,但我只从它的表单实例进行刷新......意味着 MainForm.regform.refreshCombo() 函数正在工作...... .thanx
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-02-01
    • 1970-01-01
    • 1970-01-01
    • 2020-07-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多