question

65010773 avatar image
0 Votes"
65010773 asked ·

How to bypass an event

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

windows-uwp
· 1
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

When you subscribe the SelectionChanged event, it will be raised to respond to selection changes. In addition, why now you don't want to trigger this event? Can you show more details about your expected behavior and the behavior you are getting now?

0 Votes 0 ·

1 Answer

65010773 avatar image
0 Votes"
65010773 answered ·
 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 ?







· 1 ·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

When you call the Comboyears.Items.Clear() method, the selected item will be null, so it will raise the SelectionChanged event. You can only add a judgment in the event.

0 Votes 0 ·