MDI with multiple child forms Q

M

Martin Williams

I'm developing a survey program. Currently, I have the parent form and the
survey which consists of three forms. As the user moves from one "page" or
form to the next, I would like to allow the user to go back and correct any
entries. Ideally, I would like to just hide one form as the user moves on
to the next, then show it if they decide to go back. But the problem I am
having is referencing the hidden form.

On Parent form:

sub mmuStart_click(...)
dim frm2Child as new form 2
frm2Child.mdiparent = me
frm2child.show()
mmuStart.enabled = false
end sub

Form 2 (first survey page):

sub btnNext_click(...)
dim frm3Child as new Form 3
frm3child.mdiparent = mainform /// this is referenced in a shared module
frm3child.show()
me.hide()
end sub

Form 3 (second survey page)
///this is where I'm having trouble. allowing the user to go back
sub btnBack_click(...)
???????????
end sub

I've tried numerous things, but I keep getting errors. I'm lost at this
point. Thanks for all responses.
 
N

Nak

Hi Martin,
I'm developing a survey program. Currently, I have the parent form and
the
survey which consists of three forms. As the user moves from one "page"
or
form to the next, I would like to allow the user to go back and correct
any
entries. Ideally, I would like to just hide one form as the user moves on
to the next, then show it if they decide to go back. But the problem I am
having is referencing the hidden form.

In order to access a specific instance of an object in .NET you need a
reference to it. You can either create your own global object reference to
store the instance or alternatively use the MDI parents internal array
"MdiChildren" which stores all of the references to it's children.

If you are only ever using 1 instance of the form at a time I would
suggest using a global object reference (either in a module or a utility
class),

-- in a module

Public frm2Child as form2
Public frm3Child as form3

--

sub mmuStart_click(...)
if(not (frm2Child is nothing)) then
frm2Child = new form2
frm2Child .mdiparent = me
end if
frm2child.show()
mmuStart.enabled = false
end sub

sub btnNext_click(...)
if(not (frm2Child is nothing)) then
frm3Child = new Form3
frm3child.mdiparent = mainform /// this is referenced in a shared
module
end if
frm3child.show()
me.hide()
end sub

sub btnBack_click(...)
me.hide()
frm2Child.show
end sub

It's all untested code but I think you got the idea anyway by storing
mainform in a module. Anyway, let me know if you have any problems and I'll
show you an example. Alternatively you could download an application of
mine that uses a wizard interface,

http://www.npsoftware.co.uk/freeapps.php

Either

WTR - Web The Ripper 2

or

FishNET

both of which use wizard interfaces but FishNET is allot smaller and
probably slightly easier to read. Anyway, it's a good idea to use
interfaces for this kind of thing (presumably that is what you are trying to
achieve). Take care.

Nick.
 

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