How to bypass an event

asked 2020-04-15T21:31:11.203+00:00
Shay Wilner 1,406 Reputation points

Hi

I have a combobox which the SelectionChanged event is implemented
For some reasons i don't want to raised this event how can i proceed ?

Thanks

Universal Windows Platform (UWP)
{count} votes

1 answer

Sort by: Most helpful
  1. answered 2020-04-16T10:48:41.547+00:00
    Shay Wilner 1,406 Reputation points
    Private Sub Comboyears_SelectionChanged(sender As Object, e As SelectionChangedEventArgs) Handles Comboyears.SelectionChanged
            ' do something
          end sub
    

    When i write Comboyears.Items.Clear() then the event Comboyears_SelectionChanged is raised but in fact i don't want
    One solution is to use a boolean flag
    like

     Comboyears.Items.Clear
            flagclear = true 
    
    Private Sub Comboyears_SelectionChanged(sender As Object, e As SelectionChangedEventArgs) Handles Comboyears.SelectionChanged
          if flagclear then
                    exit sub
           end if 
          ' do something
    
     End sub
    

    Or is there another solution ?