Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Triggering an event with a boolean?

$
0
0
I'm looking to raise an event to refresh a number of controls everytime a variable Boolean = False, I have scaled the "googles" searching for an answer and have come up with this code so far.

Custom Class below
Public Class Class1
    Public Property windowopen As Boolean
        Get
            Return _windowopen
        End Get
        Set(value As Boolean)
            If _windowopen = value Then Exit Property
            _windowopen = value
            OnwindowopenChanged(EventArgs.Empty)
        End Set
    End Property

    Private _windowopen As Boolean = False

    Protected Overridable Sub OnwindowopenChanged(e As EventArgs)
        RaiseEvent windowopenChanged(Me, e)
    End Sub

    Public Event windowopenChanged As EventHandler

End Class




Then in my apps main window I've inserted this code here to handle the event

   Private Sub Page_Loaded_1(sender As Object, e As RoutedEventArgs)
    windowopen = False
    End Sub
    Private WithEvents myobject As New Class1

    Private Sub myobject_windowopenChanged(sender As Object, e As EventArgs) Handles myobject.windowopenChanged
        MsgBox("Event Fired!")
    End Sub



With this code I get the 'ol reference to a non shared member requires object reference error.

I've never played around with custom events before so this is all uncharted territory for me, any help would be appreciated, hopefully Im at least on the right path.

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>