Solved

Problem with GUI not updating in MDI

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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

707 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

18 Experts available now in Live!

Get 1:1 Help Now