Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Problem with GUI not updating in MDI

Posted on 2007-12-06
2
Medium Priority
?
181 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 2000 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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

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 …
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

604 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