Results 1 to 11 of 11

Thread: Form won't close [nay bother]

  1. #1

    Thread Starter
    Hyperactive Member SjR's Avatar
    Join Date
    Jul 2001
    Location
    Birmingham, UK
    Posts
    336

    Wink 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:
    1. Private Sub lvwFolderList_ItemActivate(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lvwFolderList.ItemActivate
    2.  
    3.         Dim ndParentnode As clsTreeNode = CType(Me.ParentForm.Controls(2), TreeView).SelectedNode
    4.         Dim lv As ListView = CType(sender, ListView)
    5.         Dim tvw As TreeView = CType(Me.ParentForm.Controls(2), TreeView)
    6.  
    7.         tvw.SelectedNode = ndParentnode.Nodes(lv.FocusedItem.Index)
    8.  
    9. 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

  2. #2
    Addicted Member
    Join Date
    Mar 2001
    Location
    Devon, UK
    Posts
    181
    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.

  3. #3

    Thread Starter
    Hyperactive Member SjR's Avatar
    Join Date
    Jul 2001
    Location
    Birmingham, UK
    Posts
    336
    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

  4. #4
    Addicted Member
    Join Date
    Mar 2001
    Location
    Devon, UK
    Posts
    181
    can you post any more code??
    Wind and waves resolves all problems.

  5. #5
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Look at what I've found :
    Find out what's closing your application

    Now , I guess you know why your app. is closing.

  6. #6
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428
    Originally posted by pirate
    Look at what I've found :
    Find out what's closing your application

    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
    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!!

  7. #7

    Thread Starter
    Hyperactive Member SjR's Avatar
    Join Date
    Jul 2001
    Location
    Birmingham, UK
    Posts
    336
    Originally posted by pirate
    Look at what I've found :
    Find out what's closing your application

    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
    VB Code:
    1. Private Sub ctrlFolderList_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    2.  
    3.         Dim ndParentnode As clsTreeNode = CType(Me.ParentForm.Controls(2), TreeView).SelectedNode
    4.         Dim ndNode As clsTreeNode
    5.         Dim lv As ListView = CType(Me.Controls(0), ListView)
    6.  
    7.         For Each ndNode In ndParentnode.Nodes
    8.             lv.Items.Add(ndNode.Text, ndNode.ImageIndex)
    9.         Next
    10.  
    11. 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

  8. #8
    Frenzied Member
    Join Date
    Oct 2002
    Location
    Gammapolis
    Posts
    1,474
    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?

  9. #9

    Thread Starter
    Hyperactive Member SjR's Avatar
    Join Date
    Jul 2001
    Location
    Birmingham, UK
    Posts
    336
    '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

  10. #10
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Polite ,what do you mean exactly ?

  11. #11

    Thread Starter
    Hyperactive Member SjR's Avatar
    Join Date
    Jul 2001
    Location
    Birmingham, UK
    Posts
    336
    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
  •  



Click Here to Expand Forum to Full Width