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

Cannot open the form

P: n/a
Hi,

I am using this code to open the form...
---------------------------------------------------------------------------------------
Private frmAddUser as AddUser()
Dim fc As Form
For Each fc In Me.MdiParent.MdiChildren

If fc Is frmAddUser Then

If fc.WindowState = FormWindowState.Minimized Then

fc.WindowState = FormWindowState.Normal

End If

fc.Show()

fc.Focus()

Return

End If

Next

If (frmAddUser Is Nothing) Then

frmAddUser = New AddUser

frmAddUser.MdiParent = Me.MdiParent

frmAddUser.Show()

End If

---------------------------------------------------------------------

When I close the form and try to reopen it does not open the form. It still recognises that frmAddUser exists. How do I kill the instance when I close the form?

Thanks

Vivek

Nov 21 '05 #1
Share this Question
Share on Google+
8 Replies


P: n/a
Hi,

If the form is already a mdichild try fc.bringtofront instead of
fc.show to reshow the form

http://msdn.microsoft.com/library/de...fronttopic.asp
Ken
--------------------
"Vivek" <vi****@xtra.co.nz> wrote in message
news:eL**************@TK2MSFTNGP10.phx.gbl...
Hi,

I am using this code to open the form...
---------------------------------------------------------------------------------------
Private frmAddUser as AddUser()
Dim fc As Form
For Each fc In Me.MdiParent.MdiChildren
If fc Is frmAddUser Then
If fc.WindowState = FormWindowState.Minimized Then
fc.WindowState = FormWindowState.Normal
End If
fc.Show()
fc.Focus()
Return
End If
Next
If (frmAddUser Is Nothing) Then
frmAddUser = New AddUser
frmAddUser.MdiParent = Me.MdiParent
frmAddUser.Show()
End If
---------------------------------------------------------------------
When I close the form and try to reopen it does not open the form. It still
recognises that frmAddUser exists. How do I kill the instance when I close
the form?
Thanks
Vivek
Nov 21 '05 #2

P: n/a
Sorry but it did not work for me

"Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message
news:OX*************@TK2MSFTNGP15.phx.gbl...
Hi,

If the form is already a mdichild try fc.bringtofront instead of
fc.show to reshow the form

http://msdn.microsoft.com/library/de...fronttopic.asp
Ken
--------------------
"Vivek" <vi****@xtra.co.nz> wrote in message
news:eL**************@TK2MSFTNGP10.phx.gbl...
Hi,

I am using this code to open the form...
---------------------------------------------------------------------------------------
Private frmAddUser as AddUser()
Dim fc As Form
For Each fc In Me.MdiParent.MdiChildren
If fc Is frmAddUser Then
If fc.WindowState = FormWindowState.Minimized Then
fc.WindowState = FormWindowState.Normal
End If
fc.Show()
fc.Focus()
Return
End If
Next
If (frmAddUser Is Nothing) Then
frmAddUser = New AddUser
frmAddUser.MdiParent = Me.MdiParent
frmAddUser.Show()
End If
---------------------------------------------------------------------
When I close the form and try to reopen it does not open the form. It
still
recognises that frmAddUser exists. How do I kill the instance when I
close
the form?
Thanks
Vivek

Nov 21 '05 #3

P: n/a
Hi, maybe this can help you, I hope the code is clear otherwise feel free to
ask:

Private Sub MenuItem2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles _ MenuItem2.Click
If checkFormOpen = False Then
Dim obj As New Form2
obj.MdiParent = Me
obj.WindowState = FormWindowState.Maximized
obj.Show()
End If
End Sub

Private Function checkFormOpen() As Boolean
Dim objForm As Form
For Each objForm In Me.MdiChildren
If TypeOf objForm Is Form2 Then
objForm.WindowState = FormWindowState.Maximized
objForm.BringToFront()
Return True
End If
Next
Return False
End Function
--
Programming today is a race between software engineers striving to build
bigger and better idiot-proof programs, and the Universe trying to produce
bigger and better idiots. So far, the Universe is winning.

"Vivek" <vi****@xtra.co.nz> schreef in bericht
news:uq**************@TK2MSFTNGP09.phx.gbl...
Sorry but it did not work for me

"Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message
news:OX*************@TK2MSFTNGP15.phx.gbl...
Hi,

If the form is already a mdichild try fc.bringtofront instead of
fc.show to reshow the form

http://msdn.microsoft.com/library/de...us/cpref/html/
frlrfsystemwindowsformscontrolclassbringtofronttop ic.asp

Ken
--------------------
"Vivek" <vi****@xtra.co.nz> wrote in message
news:eL**************@TK2MSFTNGP10.phx.gbl...
Hi,

I am using this code to open the form...


--------------------------------------------------------------------------

-------------
Private frmAddUser as AddUser()
Dim fc As Form
For Each fc In Me.MdiParent.MdiChildren
If fc Is frmAddUser Then
If fc.WindowState = FormWindowState.Minimized Then
fc.WindowState = FormWindowState.Normal
End If
fc.Show()
fc.Focus()
Return
End If
Next
If (frmAddUser Is Nothing) Then
frmAddUser = New AddUser
frmAddUser.MdiParent = Me.MdiParent
frmAddUser.Show()
End If
---------------------------------------------------------------------
When I close the form and try to reopen it does not open the form. It
still
recognises that frmAddUser exists. How do I kill the instance when I
close
the form?
Thanks
Vivek


Nov 21 '05 #4

P: n/a
Vivek,

Will you please sent next time not in HTML format, and as well in a better
readable way, with all those linespaces it is almost impossible to get a
good idea what you are doing.

Probably is the only thing you want to do something as
\\\
If frmAddUser.isdisposed then
frmAddUser is new AddUser
End if
frmAddUser.show
///
I hope this helps,

Cor

Nov 21 '05 #5

P: n/a
"Vivek" <vi****@xtra.co.nz> schrieb

I am using this code to open the form...
-------------------------------------------------------------
-------------------------- Private frmAddUser as AddUser()
Dim fc As Form
For Each fc In Me.MdiParent.MdiChildren

If fc Is frmAddUser Then

If fc.WindowState = FormWindowState.Minimized Then

fc.WindowState = FormWindowState.Normal

End If

fc.Show()

fc.Focus()

Return

End If

Next

If (frmAddUser Is Nothing) Then

frmAddUser = New AddUser

frmAddUser.MdiParent = Me.MdiParent

frmAddUser.Show()

End If

---------------------------------------------------------------
------

When I close the form and try to reopen it does not open the form. It
still recognises that frmAddUser exists. How do I kill the instance
when I close the form?

You can remove the reference (frmAdduser=nothing) by handling the Closed
event of the form (declare frmadduser withevents or use addhandler to attach
the event handler). BTW, within the first If..Endif block, try
frmAdduser.Activate instead (and maybe .Show additionally because
..Activate is sometimes not enough).
Ar min

Nov 21 '05 #6

P: n/a
Thanks.

I tried this but got an error
Private Sub AddUserToolStripMenuItem_Click_1(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
AddUserToolStripMenuItem.Click
Dim fc As Form

For Each fc In Me.MdiParent.MdiChildren
If fc Is frmAddUser Then

If fc.WindowState = FormWindowState.Minimized Then
fc.WindowState = FormWindowState.Normal
End If
fc.Show()
fc.Focus()
Return
End If
Next

If (frmAddUser.IsDisposed) Then
frmAddUser = New AddUser
frmAddUser.MdiParent = Me.MdiParent
End If

frmAddUser.Show()

End Sub
"Cor Ligthert" <no************@planet.nl> wrote in message
news:ew**************@TK2MSFTNGP12.phx.gbl...
Vivek,

Will you please sent next time not in HTML format, and as well in a better
readable way, with all those linespaces it is almost impossible to get a
good idea what you are doing.

Probably is the only thing you want to do something as
\\\
If frmAddUser.isdisposed then
frmAddUser is new AddUser
End if
frmAddUser.show
///
I hope this helps,

Cor

Nov 21 '05 #7

P: n/a
Vivek,

Tell next time what the error is, that makes it much easier to give an
answer, now it still is a gues. See in line what is probably the solution to
the error.

(This is another approach and basicly the one I take, my sample I showed you
was in the way Herfried does it, which is shorter however remove that again)
I tried this but got an error
Private Sub AddUserToolStripMenuItem_Click_1(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
AddUserToolStripMenuItem.Click
Dim fc As Form

For Each fc In Me.MdiParent.MdiChildren
If fc.Name = "AddUser" Then

Or 'that I never did

If typeof fc Is AddUser Then

If fc.WindowState = FormWindowState.Minimized Then
fc.WindowState = FormWindowState.Normal
End If
fc.Show()
Return
End If
Next

frmAddUser.Show()

I hope this helps,

Cor
Nov 21 '05 #8

P: n/a
"Vivek" <vi****@xtra.co.nz> schrieb
If (frmAddUser.IsDisposed) Then


if frmadduser is nothing orelse frmaduser.isdisposed then
Armin
Nov 21 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.