L
Lloyd Sheen
I am trying to do the "Dot.Net" way of handling the following situation.
I have a handler for a textbox for changes in the text box. On the load of
the usercontrol containing the textbox I have the following code:
AddHandler ArtistName.TextChanged, AddressOf ArtistName_TextChanged
This works just fine. The problem is that in several occasions I want to
directly set the contents of the textbox and not have the event fire. In
the code to do this I have the following code:
RemoveHandler ArtistName.TextChanged, AddressOf ArtistName_TextChanged
Me.ArtistName.Text = inArtistName
AddHandler ArtistName.TextChanged, AddressOf ArtistName_TextChanged
This should first remove the handler such that the next line which sets the
text will not cause an event and then the handler is reinstated so that any
further keystrokes in the textbox will cause the event.
What happens is that on the first occurrence of the programmatic set of the
text there is no problem, the event does not happen but on each of the next
attempts the event is fired. I have verified this with the call stack.
Brand New Music
Console.exe!New_Music_Console.CDByArtistUC.ArtistName_TextChanged(Object
sender = {Text = "Laura Nyro"}, System.EventArgs e = {System.EventArgs})
Line 102 Basic
[External Code]
Console.exe!New_Music_Console.MainForm.SongViewUC1_ShowArtistAlbums(String
artist = "Laura Nyro") Line 907 + 0x1b bytes Basic
I really don't want to create a Boolean to short-circuit the handler as I
want to use this technique in cases where the code is not necessarily in the
same code file.
LS
I have a handler for a textbox for changes in the text box. On the load of
the usercontrol containing the textbox I have the following code:
AddHandler ArtistName.TextChanged, AddressOf ArtistName_TextChanged
This works just fine. The problem is that in several occasions I want to
directly set the contents of the textbox and not have the event fire. In
the code to do this I have the following code:
RemoveHandler ArtistName.TextChanged, AddressOf ArtistName_TextChanged
Me.ArtistName.Text = inArtistName
AddHandler ArtistName.TextChanged, AddressOf ArtistName_TextChanged
This should first remove the handler such that the next line which sets the
text will not cause an event and then the handler is reinstated so that any
further keystrokes in the textbox will cause the event.
What happens is that on the first occurrence of the programmatic set of the
text there is no problem, the event does not happen but on each of the next
attempts the event is fired. I have verified this with the call stack.
Brand New Music
Console.exe!New_Music_Console.CDByArtistUC.ArtistName_TextChanged(Object
sender = {Text = "Laura Nyro"}, System.EventArgs e = {System.EventArgs})
Line 102 Basic
[External Code]
Brand New MusicBrand New Music Console.exe!New_Music_Console.CDByArtistUC.setItems(String
inArtistName = "Laura Nyro") Line 96 + 0x25 bytes Basic
Console.exe!New_Music_Console.MainForm.SongViewUC1_ShowArtistAlbums(String
artist = "Laura Nyro") Line 907 + 0x1b bytes Basic
I really don't want to create a Boolean to short-circuit the handler as I
want to use this technique in cases where the code is not necessarily in the
same code file.
LS