Solved

Problem with GUI not updating in MDI

Posted on 2007-12-06
2
168 Views
Last Modified: 2010-04-23
I have a MDI parent form (frmMain.vb). When I call a form(Import.vb) in it I cant get the interface to update. When I set the form (Import.vb) as the startup form it works just fine.

Here is the code im using:

FORM MAIN (frmMain.vb)
Imports System.Windows.Forms

Public Class frmMain
    Private Sub ImportToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ImportToolStripMenuItem.Click
        Dim frmChild As New Import
        frmChild.MdiParent = Me
        frmChild.Show()
    End Sub
End Class

FORM IMPORT (Import.vb)
Imports System.Configuration.ConfigurationSettings

Public Class Import
    Private excelObj As New Sys.Cap.Data.ExcelObj
    Private formImport As Import

    Private Sub btnImport_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnImport.Click
        excelObj.PopExcel(formImport)
    End Sub
End Class

EXCEL OBJ (ExcelObj.vb)
Namespace Sys.Cap.Data
    Public Class ExcelObj
        Private formImport As Import

        Public Sub PopExcel(ByRef frm As Import)
            formImport = Import
            formImport.Label1.Text = "TEST"
            formImport.Refresh()
            Exit Sub
        End Sub
    End Class
End Namespace

Any idea why the label updates properly when I set Import.VB as the startup form and doesnt update at all when I set the frmMain.VB as the startup form?
0
Comment
Question by:bertino12
2 Comments
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 500 total points
ID: 20422941
>>>    see the ALL CAPS remarks in the code <<<

(1) Two comments for your Import class:  

Public Class Import
    Private excelObj As New Sys.Cap.Data.ExcelObj
    ' Private formImport As Import  <------- WHY IS THIS HERE? A FORM DOESN'T USUALLY NEED TO REFERENCE ITSELF!...

    Private Sub btnImport_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnImport.Click
        excelObj.PopExcel(Me) ' I ASSUME YOU WANT TO PASS A REFERENCE TO THE CURRENT FORM?
    End Sub
End Class

(2) Your passed in variable is called "frm"...but you are using "Import" (a type) instead?

    Public Class ExcelObj
        Private formImport As Import

        Public Sub PopExcel(ByRef frm As Import)
            formImport = frm ' <----- USE THE VARIABLE NAME THAT WAS PASSED IN!
            formImport.Label1.Text = "TEST"
            formImport.Refresh()
            Exit Sub
        End Sub

    End Class

0
 

Author Closing Comment

by:bertino12
ID: 31413233
Thank you very much for your time.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How do sunrise and sunset times change with altitude 14 35
VB.net capture  result of a SQL query in variables 3 20
System.net.Sockets Error 5 26
Groupbox Control ? 2 17
Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question