?
Solved

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

Posted on 2009-05-04
11
Medium Priority
?
171 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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 2000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

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…
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…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

752 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