How to display names of mdi children form been viewed on status bar

PRAISE PHS

Well-known member
Joined
Jun 2, 2011
Messages
58
Programming Experience
Beginner
Hi All,
Pls help me out with this issue:

In my app, I have 6 mdi children forms on tool strip buttons that are docked at the top of my mdi parent form. I then docked a status bar with a status label at the buttom of my parent form. How do I do program the app such that whenever any form is displayed on my parent form, the name of such child form should be displayed on my status bar for the user. Also, if I have multiple children forms displayed on my parent form, the name of the top most form should be shown on my status bar. If I also decide to close the top most form, the name of next top most form should be displayed on status bar. Finally, if there are no form(s) displayed on the parent window, the name of the parent window should be shown on my status bar. Thanks and I would really appreciate a prompt response.
 

JohnH

VB.NET Forum Moderator
Staff member
Joined
Dec 17, 2005
Messages
15,583
Location
Norway
Programming Experience
10+
Use MdiChildActivate event and get ActiveMdiChild property.
 

JohnH

VB.NET Forum Moderator
Staff member
Joined
Dec 17, 2005
Messages
15,583
Location
Norway
Programming Experience
10+
Show me how you would set up an event handler for MdiChildActivate event.
 

PRAISE PHS

Well-known member
Joined
Jun 2, 2011
Messages
58
Programming Experience
Beginner
Show me how you would set up an event handler for MdiChildActivate event.

My code below actually changes the status bar label to the text property of each windows forms. But, I want the app to work as I've stated in my first post. Pls, kindly help.


VB.NET:
Private Sub mdiParent_MdiChildActivate(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.MdiChildActivate
        Try
           
            If ToolStripButtonProducts.Selected = Enabled Then
                ToolStripStatusLabel1.Text = "PRODUCTS"

            ElseIf ToolStripButtonStockIn.Selected = Enabled Then
                ToolStripStatusLabel1.Text = "STOCK-IN DETAILS"

            ElseIf ToolStripButtonStockOut.Selected = True Then
                ToolStripStatusLabel1.Text = "STOCK-OUT DETAILS"
            
Else
                ToolStripStatusLabel1.Text = "APPLICATION EXPLORER"
            End If




Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
 

JohnH

VB.NET Forum Moderator
Staff member
Joined
Dec 17, 2005
Messages
15,583
Location
Norway
Programming Experience
10+
So you know how to use MdiChildActivate event, and you know how to set StatusLabel.Text.
As you've read the documentation for ActiveMdiChild property, you know that it returns Nothing when there is no active MDI child.
Now get rid of all the code in event handler and instead set your StatusLabel.Text conditionally to ActiveMdiChild.Name or Me.Name.
 
Top Bottom