AddEvent but no RemoveEvent??

Discussion in 'Questions (Windows Mobile)' started by LineCutter, Apr 19, 2008.

  1. LineCutter

    LineCutter Active Member Licensed User

    I'm probably missing something, but when I add a panel & some buttons, dispose of them all & then call the routines again I get the button_click sub called twice. Debugging shows that there is no detour between endsub & the first statement of the same sub.
    Bug in B4PPC or in my programming??

    Called from an imagebutton:
    (Prefstable has 4 locations, one hardcoded as "All")
    Code:
    Sub OtherButton_ButtonDown
        AddPanel(
    "Main""OtherPanel"1010 ,225255)
        spacer=
    10
        ButtonHeight=(Otherpanel.Height-((PrefsTable.rowcount+
    1)*spacer))/PrefsTable.rowcount
        Buttonwidth=Otherpanel.Width-(
    2*spacer)
        
    For i = 0 To prefstable.rowcount-1
            AddButton(
    "OtherPanel", Prefstable.cell("Location",i)&"Button",spacer,((i+1)*spacer)+(i*buttonheight),ButtonWidth, ButtonHeight,Prefstable.cell("Location",i))
            
    'AddEvent (Control Name, Event Name, Sub Name)
            AddEvent (Prefstable.cell("Location",i)&"Button", Click, "SetFilter")
        
    Next
        Otherpanel.bringtofront
    End Sub
    Calls this:
    Code:
    Sub SetFilter
        
    If Sender.text="All" Then
            jobtable.Filter(
    "Done=''")
        
    Else
            jobtable.Filter(
    "Location='"&Sender.text&"'")
        
    End If
        jobtable.SelectCell(
    "index",0)
        
    For i = 0 To prefstable.rowcount-1
            
    Control(Prefstable.cell("Location",i)&"Button"button).dispose
        
    Next
        Otherpanel.dispose
    End Sub
    Which repeats twice on the second call (button click) & errors because the sender doesn't exist for the second loop through the sub. Curiously, there are only 2 loops if I opt to continue after the error.
     
  2. agraham

    agraham Expert Licensed User

  3. LineCutter

    LineCutter Active Member Licensed User

    Thanks - I didn't mange to find that thread myself, but it makes it all clear now.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice