activate Statusbar from mdichild form

R

rat

i am having 3 panels(0,1 & 2) in a Statusbar.

Using MDI form, i can access and set the text for the
panels(0 and 2)..

But how can i access the panel(1) from MDI Child form.
like frmmdi.SB.Panels(1).text = "files saved.."

frmmdi --> Mdi Form name
SB --> StatusBar

Advanced Thanks.
regards,
Rat
 
F

Fergus Cooney

Howdy Rat,

Each Mdi child form (class RattyForm) has an MdiParent property. This
property has the type Form, whereas your Mdi parent Form is more special than
that - class RattusForm. What you must do, therefore, is cast your RattyForm's
MdiParent to the right type.

In a RattyForm
Dim sbRat As StatusBar = DirectCast (Me.MdiParent, RattusForm).SB
sbRat.Panels (1) = "Files nibbled."

That's the quick and direct way. But what if, one day you decide to change
those panels around or add one, etc? Will you have to change that '1' is all
RattyForms? Yep. What if perchance you miss one? [Not a chance - for are you
not the Rat?!]

But is there an alternative? Yep again.

Have a method on the RattusForm which will set that Panel for the Ratties.

'Not required but recommended. Could even use an Enum.
Private Const kRattusPanelA As Integer = 0
Private Const kRattyPanel As Integer = 1
Private Const kRattusPanelB As Integer = 2

Public Sub SetRattyInfo (sRattyString As String)
Me.Panels (kRattyPanel) = sRattyString
End Sub

This allows you to change your status bar panels at will and only have to
change the constants at the top of RattusForm.

And now, in the RattyForms, you'd have this perfectly stable code.

DirectCast (Me.MdiParent, RattusForm).SetRattyInfo ("Files nibbled.")

Regards,
Fergus

ps I'm a Cat but I've just eaten so you're safe! ;-)
 
G

Guest

Hi Fergus alias (cat)

Thanks, its realy useful for me right now.

thanks once again.

Regards,
Rat
 
H

Herfried K. Wagner [MVP]

* "rat said:
i am having 3 panels(0,1 & 2) in a Statusbar.

Using MDI form, i can access and set the text for the
panels(0 and 2)..

But how can i access the panel(1) from MDI Child form.
like frmmdi.SB.Panels(1).text = "files saved.."

frmmdi --> Mdi Form name
SB --> StatusBar

\\\
DirectCast(Me.MdiChildren(1), ChildForm).StatusBar1.Panels(1).Text
///
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top