Click to See Complete Forum and Search --> : Form won't close [nay bother]
SjR
Dec 11th, 2002, 06:33 AM
My form won't close - the 'closing' and 'closed' events are not firing when I click on the 'X'
I've isolated this piece of code as the culprit... activated when you double click on a listview item.
Private Sub lvwFolderList_ItemActivate(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lvwFolderList.ItemActivate
Dim ndParentnode As clsTreeNode = CType(Me.ParentForm.Controls(2), TreeView).SelectedNode
Dim lv As ListView = CType(sender, ListView)
Dim tvw As TreeView = CType(Me.ParentForm.Controls(2), TreeView)
tvw.SelectedNode = ndParentnode.Nodes(lv.FocusedItem.Index)
End Sub
The list view is part of a user control that I've created which is added to a panel in the main form that I'm trying to close. The referenced TreeView is on the main form.
Anyone see what I'm missing?
Thanks in advance for any help.
:):)
cim3
Dec 11th, 2002, 08:41 AM
The code you posted seems to have nothing to do with closing your main form or any form for that matter.
Forms generally don't close because you have another form open.
Make sure that all your forms are in a collection so you can see what you have current at any one time.
SjR
Dec 11th, 2002, 09:21 AM
I agree that it doesn't seem to have anything to do with it.... but if this piece of code is commented out, the form will close fine. The project only contains 1 form, so it can't be because another is open... I'm confused :confused:
cim3
Dec 11th, 2002, 10:38 AM
can you post any more code??
Pirate
Dec 11th, 2002, 11:01 AM
Look at what I've found :
Find out what's closing your application (http://www.codeproject.com/useritems/FormClosing.asp)
Now , I guess you know why your app. is closing.
MrPolite
Dec 11th, 2002, 09:22 PM
Originally posted by pirate
Look at what I've found :
Find out what's closing your application (http://www.codeproject.com/useritems/FormClosing.asp)
Now , I guess you know why your app. is closing.
Someone in GotDotNet forums answered to the same question that I asked, and I posted that in codeproject.com so people like you could see it, because I thought it's very helpful. But some people said I was trying to "steal" code and take credit for it. Stupid :(
SjR
Dec 12th, 2002, 03:07 AM
Originally posted by pirate
Look at what I've found :
Find out what's closing your application (http://www.codeproject.com/useritems/FormClosing.asp)
Now , I guess you know why your app. is closing.
umm
Originally posted by SjR
My form won't close - the 'closing' and 'closed' events are not firing when I click on the 'X'.
I put a message box in the closing and closed events of the form, but the msgbox was not showing when I clicked on the X on the form. This says to me that these events are not being triggered at all. Thanks for the link though - may prove useful in future :)
This is the controls load event
Private Sub ctrlFolderList_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim ndParentnode As clsTreeNode = CType(Me.ParentForm.Controls(2), TreeView).SelectedNode
Dim ndNode As clsTreeNode
Dim lv As ListView = CType(Me.Controls(0), ListView)
For Each ndNode In ndParentnode.Nodes
lv.Items.Add(ndNode.Text, ndNode.ImageIndex)
Next
End Sub
Though the main form will still close if the control is loaded... its only when the items are activated that the form refuses to go away.
Lunatic3
Dec 12th, 2002, 09:43 AM
This happens with dialog forms during load event, that is you can not close it despite closing event fired! You said you have only one form in your application but this:
CType(Me.ParentForm.Controls(2), TreeView).SelectedNode
tells me there is a parent form in your project too. Am i wrong?
SjR
Dec 12th, 2002, 10:27 AM
'Me' refers to the usercontrol "ctrlFolderList" and 'parentform' refers to the form that the control has been added to - the only form in the project.
Pirate
Dec 12th, 2002, 07:54 PM
Polite ,what do you mean exactly ?
SjR
Dec 13th, 2002, 04:29 AM
I've had to change the way this user control is used, which means the coding has changed, and so I no longer have this problem! :)
I hereby re-classify this thread as "no longer requiring a resolution even though I don't know the answer" or "nay bother" for short. ;)
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.