Toolbar and mdi child forms

  • Thread starter Jamie Di Natale
  • Start date
J

Jamie Di Natale

I have a MDI Parent form with a toolbar that has a Next and Previous button
on it.

I open up a MDI Child form, that has two routines, called nextrec and
prevrec.

When I hit the Next or Previous button on the parent window, I want the
corresponding routine (nextrec/prevrec) on the child form to fire.

How is this done in VB.NET 2003 ???

TIA.

Jamie.
 
G

Guest

This assumes that nextrec and prevrec are public methods

private void next_Click(object sender, EventArgs e) // handler for "Next" butto

((MyChildForm)ActiveMdiChild).nextrec()


private void prev_Click(object sender, EventArgs e) // handler for "Previous butto

((MyChildForm)ActiveMdiChild).prevrec()
 
J

Jamie Di Natale

Unfortunately, this does not work in VB.

How do you create a reference to a type from the ActiveMdiChild
properties ???,
instead of issuing Dim myChildForm As members

Since I have many child forms, it does not make sense to add each form
to the prev/next button click events.
 
A

Armin Zingler

Jamie Di Natale said:
I have a MDI Parent form with a toolbar that has a Next and Previous
button on it.

I open up a MDI Child form, that has two routines, called nextrec
and prevrec.

When I hit the Next or Previous button on the parent window, I want
the corresponding routine (nextrec/prevrec) on the child form to
fire.

How is this done in VB.NET 2003 ???

If typeof me.activemdichild is MyChildClass then
directcast(me.activemdichild, MyChildClass).nextrec
end if


--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html
 
J

Jamie Di Natale

'MainScreen with toolbar
Dim membersMDIChild As New members
membersMDIChild.MdiParent = Me
membersMDIChild.Show()

NextRec_Click....

If typeof me.activemdichild is members then
directcast(me.activemdichild, members).nextrec
end if

Since, I have multiple mdichild's, how can I change class members, to
what ever the class is of the activeform instead of explicitly typing it
in ???

So, when you click on the next button on the toolbar of the parent form,
it does the public sub nextrec of the activemdichild form.

In Visual FoxPro, all I have to do is call _screen.activeform.nextrec().
 
G

Guest

I apologize. Sometimes I forget which forum I'm in

CType(Me.ActiveMsiChild, members).nextrec()

It's the same as what you're used to in FoxPro, except that you need to cast the form returned by Me.ActiveMdiChild to the type that contains the definition for nextrec

Charlie
 
A

Armin Zingler

Jamie Di Natale said:
'MainScreen with toolbar
Dim membersMDIChild As New members
membersMDIChild.MdiParent = Me
membersMDIChild.Show()

NextRec_Click....

If typeof me.activemdichild is members then
directcast(me.activemdichild, members).nextrec
end if

Since, I have multiple mdichild's, how can I change class members,
to what ever the class is of the activeform instead of explicitly
typing it in ???

So, when you click on the next button on the toolbar of the parent
form, it does the public sub nextrec of the activemdichild form.

I guess the child forms have all different types, but the method names are
the same (nextrec...), right? There are two "clean" ways:

- Derive your child forms from the same base form. The base form contains
the common procedure, so you can write directcast(me.activemdichild,
commonform).nextrec

- Write and interface containing the common members and implement it in all
childs capable of this set of members. It's pretty easy to do. Code would
be: directcast(me.activemdichild, ICommoninterface).nextrec


--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html
 

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