[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

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

Posted on 2009-05-04
11
Medium Priority
?
174 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

Independent Software Vendors: 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

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
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…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

650 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