Solved

I need to change the child screen Active status from another child screen.

Posted on 2009-05-04
11
163 Views
Last Modified: 2012-05-06
Friends,
When criteria is met on one child screen, I need to Activate() another child screen (bring it to the top).

When I declare them from my parent, it is as follows:

Dim f1 As ResultViewerForm
Dim f2 As ResultViewerRPForm
Dim f3 As IndyResultViewerForm

Now, if I want to make f3 Active, from the Parent form, I would simply do this

    Private Sub ActivateF3ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ActivateF3ToolStripMenuItem.Click
        F3.Activate
    End Sub

or

   Public Sub ActivateIndyResultViewerForm()
         f3.Activate()
    End Sub

However, if I call  the ActivateIndyResultViewerForm sub from a child form, it steps through the code in the sub (specifically f3.Activate()), but it won't actually bring the said child form to the front.

Is there another way to do it?

Thanks in advance!

Eric
0
Comment
Question by:indy500fan
  • 6
  • 5
11 Comments
 
LVL 85

Expert Comment

by:Mike Tomlinson
Comment Utility
Instead of Activate(), try BringToFront().
0
 

Author Comment

by:indy500fan
Comment Utility
Idle Mind:

It's not an issue of the Activate() function not working, it will do the job when called from the Parent form, it will not however work when calling it from the child.

Do you mean to say that using BringToFront() will work from the child form?
0
 
LVL 85

Expert Comment

by:Mike Tomlinson
Comment Utility
When you say "child", how are you displaying the child form?

...and just as important, how are you calling the PARENT function ActivateIndyResultViewerForm()?
0
 

Author Comment

by:indy500fan
Comment Utility
Well, the child form is created in the parent in the following manner:

    Dim f1 As ResultViewerForm
    Dim f2 As ResultViewerRPForm
    Dim f3 As IndyResultViewerForm

    Private Sub mdiMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
...
        Try
            f1 = New ResultViewerForm()
            f1.MdiParent = Me
            f1.Show()

            f3 = New ResultViewerRPForm()
            f3.MdiParent = Me
            f3.Show()

       Catch ex As Exception

        End Try

    End Sub

I then tried to call the parent function in the following manner...

mdiMain.ActivateIndyResultViewerForm()

0
 
LVL 85

Expert Comment

by:Mike Tomlinson
Comment Utility
Gotcha...try:

        Dim M As mdiMain = CType(Me.MdiParent, mdiMain)
        M.ActivateIndyResultViewerForm()

Or make "f1", "f2" and "f3" Public Shared so you can access them from anywhere:

    Public Shared f1 As ResultViewerForm

Accessed with:

    mdiMain.f1.Activate()
0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

Author Comment

by:indy500fan
Comment Utility
Well, when I tried a variation of that earlier, I got a dreaded cross-threaded error, because I wasn't using a delegate.  Not even sure how to create a delegate for this one.
0
 
LVL 85

Expert Comment

by:Mike Tomlinson
Comment Utility
The POSTED code alone shouldn't cause any cross-thread errors...  =\

Under what "circumstances" do the forms get activated?

    "When criteria is met on one child screen..."

What exactly are you doing when the criteria is met?
0
 

Author Comment

by:indy500fan
Comment Utility
doh!  Yeah, the criteria comes from decoding data that happens on another thread (a serial stream).

Sorry, forgot to mention that part.  :)
0
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 500 total points
Comment Utility
With an invoke/delegate call, it might look like this in mdiMain:
    Public Delegate Sub ShowForm()
 

    Public Sub ActivateIndyResultViewerForm()

        If Me.InvokeRequired Then

            Me.Invoke(New ShowForm(AddressOf ActivateIndyResultViewerForm), New Object() {})

        Else

            f3.Activate()

        End If

    End Sub

Open in new window

0
 

Author Comment

by:indy500fan
Comment Utility
I will try in the morning!  Thanks for your help so far!
0
 

Author Closing Comment

by:indy500fan
Comment Utility
That works perfectly!
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

763 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

6 Experts available now in Live!

Get 1:1 Help Now