Solved

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

Posted on 2009-05-04
11
167 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
[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
  • 6
  • 5
11 Comments
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 24298126
Instead of Activate(), try BringToFront().
0
 

Author Comment

by:indy500fan
ID: 24298139
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 86

Expert Comment

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

...and just as important, how are you calling the PARENT function ActivateIndyResultViewerForm()?
0
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 

Author Comment

by:indy500fan
ID: 24298205
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 86

Expert Comment

by:Mike Tomlinson
ID: 24298236
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
 

Author Comment

by:indy500fan
ID: 24298264
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 86

Expert Comment

by:Mike Tomlinson
ID: 24298310
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
ID: 24298335
doh!  Yeah, the criteria comes from decoding data that happens on another thread (a serial stream).

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

Accepted Solution

by:
Mike Tomlinson earned 500 total points
ID: 24298358
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
ID: 24298511
I will try in the morning!  Thanks for your help so far!
0
 

Author Closing Comment

by:indy500fan
ID: 31578696
That works perfectly!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

738 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