mdiParent/Child Forms - Argh

G

Guest

I'm new to VB.Net 2003 - (2 weeks in) so this MAY be straightforward...
(Things changed since Octal Assembler I see !!!)

I'll try to lay this out in a way that makes sense

I created a MdiParent form

In that form I want Child forms to apear BASED ON BUTTON Control Click Event

The Child needs to appear in the same location - Basically, turn ChildForm1
off and ChildForm2 on etc etc only one childform at a time

I have set StartPosition to Manual and entered the appropriate x,y

If I use the following code in the Main_Load Event of the mdiParent, the
form goes in the proper place - everything works great

Dim objDID As New fclDID
objDID.MdiParent = Me
objDID.Show()

Now, because I have many buttons (sounds like a silly thing to do, but in
this case...), I created two modules - one to Hide (or close - can't get
either to work - I want to close the 'old' form ideally) the old form and one
to show the new form (requested by the button click event)

So - basically the parent form holds the Click event, sets up some variables
- changes button colours etc etc and calls the Hide Sub in the Hide module
and then calls the Show sub in the Show module (both are public subs)

I traced the button click event to make sure that everything was passing
correctly - and it is

BUT

the child forms show up OUTSIDE the parent form - and when I try to
close/hide the 'old' form (by clicking a button on the parent), nothing
happens...

I have tried too many things to mention here - hehe - but one thing I should
mention is that I moved BOTH Public Subs out of the modules and into the
mdiParent code and that did NOT change anything

While I have not gone blind looking for answers, the medication is wearing
off and I could really use some help !!!!

Cheers

Scott
 
A

AMDRIT

Break it apart and start with a more simplistic approach, then add
functionality.

Class FrmMaster

private enum ToggleStates as integer
tsShowNone = 0
tsShowChild1 = 1
tsShowChild2 = 2
end enum

private m_ChildForm as Form
private m_ToggleState as ToggleStates = ToggleStates.tsShowNone

Sub cmdToggle_Click(sender, e)

dim myState as integer
dim fTop, fLeft, fHeight, fWidth as integer

myState = ctype(m_ToggleState, integer) + 1
if myState > 2 then myState = 0

m_ChildForm.Close
m_childForm.Dispose

select case myState
case ToggleStates.tsShowNone
case ToggleStates.tsShowChild1

m_childform = new frmChild1
m_childform.mdiParent = me

fTop =
fLeft =
fHeight =
fWidth =

case ToggleStates.tsShowChild2

m_childform = new frmChild1
m_childform.mdiParent = me

fTop =
fLeft =
fHeight =
fWidth =

end select

if not m_childForm is nothing then
m_childform.show
m_childform.Startuposition = FormStartPosition.Manual
m_childform.top = fTop
m_childform.left = fLeft
m_childform.height = fHeight
m_childform.width = fWidth
end if

end Sub

End Class
 

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