|
-
Dec 11th, 2002, 07:33 AM
#1
Thread Starter
Hyperactive Member
Form won't close [nay bother]
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.
VB Code:
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.

Last edited by SjR; Dec 13th, 2002 at 05:31 AM.
Another satisfied customer 
-
Dec 11th, 2002, 09:41 AM
#2
Addicted Member
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.
Wind and waves resolves all problems.
-
Dec 11th, 2002, 10:21 AM
#3
Thread Starter
Hyperactive Member
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
Another satisfied customer 
-
Dec 11th, 2002, 11:38 AM
#4
Addicted Member
can you post any more code??
Wind and waves resolves all problems.
-
Dec 11th, 2002, 12:01 PM
#5
Sleep mode
Look at what I've found :
Find out what's closing your application
Now , I guess you know why your app. is closing.
-
Dec 11th, 2002, 10:22 PM
#6
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
rate my posts if they help ya!
Extract thumbnail without reading the whole image file: (C# - VB)
Apply texture to bitmaps: (C# - VB)
Extended console library: (VB)
Save JPEG with a certain quality (image compression): (C# - VB )
VB.NET to C# conversion tips!!
-
Dec 12th, 2002, 04:07 AM
#7
Thread Starter
Hyperactive Member
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
VB Code:
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.
Another satisfied customer 
-
Dec 12th, 2002, 10:43 AM
#8
Frenzied Member
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?
-
Dec 12th, 2002, 11:27 AM
#9
Thread Starter
Hyperactive Member
'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.
Another satisfied customer 
-
Dec 12th, 2002, 08:54 PM
#10
Sleep mode
Polite ,what do you mean exactly ?
-
Dec 13th, 2002, 05:29 AM
#11
Thread Starter
Hyperactive Member
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.
Another satisfied customer 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|