Listview Itemactivate stops working

Kane Jeeves

Active member
Joined
May 17, 2006
Messages
44
Programming Experience
5-10
I have two forms frmA, frmB. I have a listview on frmA with a couple items with tags. In the listviews Itemactivate event I get the FocusedItem's tag and open frmB. Everything works fine until I close frmB and come back to frmA. The original item is still selected but the Itemactivate no longer opens frmB. I can step right into the frmB.Show line on frmA, it's just that frmB nevers shows.

Private Sub ListView1_ItemActivate(...) Handles ListView1.ItemActivate
Select Case ListView1.FocusedItem.Tag
Case "showfrmB"
frmB.Show() '<<<frmB doesn't Show 2nd time around
End Select
End Sub

frmB then does this: Me.Close()

I've tried adding Hides, Activates, etc. with no luck. Any suggestions?

Kane
 
Solved

Well it doesn't make sense I guess, but instead of doing frmB.Show() I used frmB.ShowDialog() and NOW everything works fine. This is a windows mobile 6 app, maybe that was the difference??
 
It was because it could not open a disposed form (default instance). Had you made a new instance it would have been ok. And would check to make sure you don't have an instance open before making a new one - if needed.
VB.NET:
Dim frm As New frmB
frm.Show()
 
Hmmm. What's the difference between a disposed form, and one that was never open in the first place? Point being, why does a simple frmB.Show work the first time, but a DIM x as New frmB, frmB.Show is needed the 2nd time?
 
You called the default instance which is fine if you only call it once - after that you will get the error. Your program has disposed of the form as it should. The new instances get disposed of too, but since you make a new shiny one each time time this is ok. I know there is probably a more technical answer out there, but that's mine.
 
Back
Top