By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,702 Members | 1,771 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,702 IT Pros & Developers. It's quick & easy.

activate Statusbar from mdichild form

P: n/a
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
Nov 20 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
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! ;-)
Nov 20 '05 #2

P: n/a
Hi Fergus alias (cat)

Thanks, its realy useful for me right now.

thanks once again.

Regards,
Rat
-----Original Message-----
Howdy Rat,

Each Mdi child form (class RattyForm) has an MdiParent property. Thisproperty has the type Form, whereas your Mdi parent Form is more special thanthat - class RattusForm. What you must do, therefore, is cast your RattyForm'sMdiParent 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 changethose panels around or add one, etc? Will you have to change that '1' is allRattyForms? Yep. What if perchance you miss one? [Not a chance - for are younot 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 tochange 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! ;-)
.

Nov 20 '05 #3

P: n/a
* "rat" <an*******@discussions.microsoft.com> scripsit:
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
///

--
Herfried K. Wagner
MVP VB Classic, VB.NET
<http://www.mvps.org/dotnet>
Nov 20 '05 #4

P: n/a
Oops
Nov 20 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.