Solved

Problem with GUI not updating in MDI

Posted on 2007-12-06
2
165 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

813 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now