Solved

Update status bar of MDI parent from child forms in windows application

Posted on 2004-10-07
13
1,165 Views
Last Modified: 2007-12-19
Hi,
I need to know the best way of coding that will write to status bar panels of mdi parent from child forms.

Thanks in advance!
0
Comment
Question by:Coolcld
  • 4
  • 4
  • 3
  • +2
13 Comments
 
LVL 10

Expert Comment

by:123654789987
ID: 12256462
In your MDI parent class u can have a static method, that updates the Status bar text. Then u can call this static method from the Child forms
0
 

Author Comment

by:Coolcld
ID: 12256515
Hi,
Thanks for the comment. Do I need to share the status bar control also? Because I am not able to access 'Friend' type control inside shared method.

Thanks in advance!
0
 
LVL 7

Expert Comment

by:J_Mak
ID: 12256516
To obtain the Mdi Parent of the a child form, try the following:

'this is in the child form
Me.MdiParent.StatusBar1.Text = "I'm a child"

That will do it for you. Cheers.
0
 

Author Comment

by:Coolcld
ID: 12256578
Hi 123654789987,
How to code a static method in windows application? I used shared in place of static. Is it correct?

Method:
Public Shared Sub WriteStatus(ByVal strMessage As String)
            stsMain.Panels(0).Text = strMessage
End Sub

Staus bar Control:
Shared WithEvents stsMain As System.Windows.Forms.StatusBar

This works. But need to know whether it is the best way of doing.
0
 
LVL 7

Expert Comment

by:J_Mak
ID: 12256655
Can't you just perform this command:

Me.MdiParent.StatusBar1.Panels(0).Text = strMessage

You wouldn't need to write your own function since you can access the parent's status bar using properties.




0
 

Author Comment

by:Coolcld
ID: 12257012
Hi  J_Mak,
Iam not able to access statusbar of mdiparent from child.
 i.e.Me.MdiParent.stsMain is not accepted. Did you tried this and worked for you? Please let me know.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 18

Expert Comment

by:armoghan
ID: 12257184
StatusBar1 seems to be public in J_Mak  post
0
 
LVL 18

Expert Comment

by:armoghan
ID: 12257188
and you need to cast it to the name of your MDI parent
0
 
LVL 18

Expert Comment

by:armoghan
ID: 12257193
something like this in C#
((MyParentForm)this.MdiParent).stsMain
0
 
LVL 7

Accepted Solution

by:
J_Mak earned 100 total points
ID: 12258346
Oh ok.... i only had a guess at it... I have just realised that it may not work. I think you should have a property in your Parent class like so:

   Shared WithEvents stsMain As System.Windows.Forms.StatusBar

   Friend ReadOnly Property GetStatusBar() As StatusBar
        Get
            GetStatusBar= stsMain
        End Get
    End Property

In your child form you can do this to access the parent's status bar:

Me.MdiParent.GetStatusBar.Panels(0).Text = strMessage

Hope that works now.
0
 
LVL 8

Assisted Solution

by:wguerram
wguerram earned 25 total points
ID: 12268263
You have to change the Modifiers property of the status bar to public in order to have access.

this property can be changed at design time.
0
 

Author Comment

by:Coolcld
ID: 12274362
Hi,
I made the status bar as 'public' and added the below code

Me.MdiParent.GetStatusBar.Panels(0).Text = strMessage

It works fine. Thanks.
0
 
LVL 7

Expert Comment

by:J_Mak
ID: 12274407
no worries, glad i could help.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How can one ComboBox's items be determined by another? 9 26
Red error squiggly on vb.net 7 27
DataGridView Events ? 3 37
Pagebreak issue while printing the aspx page 3 11
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…
Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

929 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now