Results 1 to 3 of 3

Thread: [RESOLVED] which event to use to save TextBox text?

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2007
    Location
    cobwebbed to PC
    Posts
    311

    Resolved [RESOLVED] which event to use to save TextBox text?

    Hi Folks

    I have a form with a TextBox control.

    The text entered in the text box is saved to an object in the TextBox.Validated event handler.

    When the user hits the save ToolStripButton the object is serialized and saved to the relevant file.

    However, if the user edits the TextBox text, but does not leave the TextBox before clicking the save button then the TextBox events, such as Validated, Validating, LostFocus, etc, do not appear to occur, or at least do not occur before the save button Click event is raised and handled. This means that the edits to the text do not get saved to the object before the object is serialized and saved.

    What event or series of operations is best to use to ensure that the most correct method is used and any changes to the TextBox Text are always saved?

    Will I have to resort to using the TextBox TextChanged event, or even the KeyPress event, and saving the text every time any single char is changed??

    Thanks
    Thanks

  2. #2
    Still learning kebo's Avatar
    Join Date
    Apr 2004
    Location
    Gardnerville,nv
    Posts
    3,762

    Re: which event to use to save TextBox text?

    Put a call to Me.Validate in the save tool strip handler before doing anything else. That should force the control with the focus to validate itself first.
    Process control doesn't give you good quality, it gives you consistent quality.
    Good quality comes from consistently doing the right things.

    Vague general questions have vague general answers.
    A $100 donation is required for me to help you if you PM me asking for help. Instructions for donating to one of our local charities will be provided.

    ______________________________
    Last edited by kebo : Now. Reason: superfluous typo's

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2007
    Location
    cobwebbed to PC
    Posts
    311

    Re: which event to use to save TextBox text?

    Great, thanks kebo!
    Thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width