Solved

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

Posted on 2009-05-04
11
166 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
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 85

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
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

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 85

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 85

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 85

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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 …
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…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

828 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