locked
textchanged - strange behaviour RRS feed

  • Question

  • Hi,

    I have a form which has some text boxes that hold folder and directory paths. These are validated when typed in and I've used a shared event to determine when to validate.

     

    Private Sub Text_box_File_changed(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles  Config_path.TextChanged,  Script_path.TextChanged

    the problem I'm experiencing is that when the app if fired up I get the previously saved settings from a config file and populate the text boxes. This fires the Textchanged event. However, what happens is that only one of 3 boxes are filled out. I have to load another two times for them to appear.

    What appears to happen is that the first textchanged event is fired and it doesn't fire again as each textbox is populated. This seems to be proved by repeating lines like :

    config.Item(

    "Template_path") = Template_path.Text
    config.Item(
    "Config_path") = Config_path.Text
    config.Item(
    "Script_path") = Script_path.Text

    This happens even if I use a separate event handler.

    Under normal operation, ie. when the textbox is changed manually or via a file dialog it all works fine, it's just at the beginning when I load from my config file.

    This behaviour seems odd as I'm pretty sure that the event seems to be disabled after the first firing.

    How does one get over this? Ideally it'd be nice to to disable the event at the beginning whilst loading values into the textboxes as I only really want to capture textbox changes by the user.

    Friday, February 26, 2010 2:09 PM

Answers

  • Remove the Handles clause from your event handler and add it in as a handler at the end of your form load event handler, e.g:

    AddHandler Config_path.TextChanged, Addressof Text_box_File_changed

    Friday, February 26, 2010 2:27 PM

All replies

  • Remove the Handles clause from your event handler and add it in as a handler at the end of your form load event handler, e.g:

    AddHandler Config_path.TextChanged, Addressof Text_box_File_changed

    Friday, February 26, 2010 2:27 PM
  • Remove the Handles clause from your event handler and add it in as a handler at the end of your form load event handler, e.g:

    AddHandler Config_path.TextChanged, Addressof Text_box_File_changed


    Thanks for that, just what I was looking for
    Friday, February 26, 2010 5:35 PM