Status Bar Question

Rat

Well-known member
Joined
Aug 2, 2005
Messages
72
Location
Somewhere between 0 and 1
Programming Experience
1-3
Status Bar Question - [RESOLVED]

I have three forms, one as a parent, and two childs.

I've placed a statusbar on the parent, how do i make the statusbar controls visible on the other forms i have in the workspace ?

- Thanks.
 
Last edited:
I would suggest creating a public method in the parent to actually set the text of its own status bar and passing a reference to the parent form to each child. If your app uses MDI then you already have a reference, otherwise I suggest passing one in each child's constructor. The child forms can then assign that reference to a class level variable and call its public methods, including the one to write to the status bar, whenever they like.
 
jmcilhinney said:
I would suggest creating a public method in the parent to actually set the text of its own status bar and passing a reference to the parent form to each child. If your app uses MDI then you already have a reference, otherwise I suggest passing one in each child's constructor. The child forms can then assign that reference to a class level variable and call its public methods, including the one to write to the status bar, whenever they like.

Could i get a example bro, if it ain't too much of a trouble.
 
Something like this in the parent:
VB.NET:
	Public Sub SetStatusBarText(ByVal text As String)
		Me.StatusBar1.Text = text
	End Sub
Something like this in the child:
VB.NET:
	Private Sub SetStatusBarText(ByVal text As String)
		DirectCast(Me.MdiParent, Form1).SetStatusBarText(text)
	End Sub
I've used Form1 as the type of the parent but you can change that to the correct type. The MdiParent property is of type Form, so you need to cast it as the correct type to access members specific to that type. I've put the code in the child form into a procedure but you can call the parent method anywhere you like in the child.
 
Back
Top