Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Newbie Question

Newbie Question

Scheduled Pinned Locked Moved C#
questiondatabase
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    kruegersck
    wrote on last edited by
    #1

    I have a form that has many text boxes on it. When the user selects a record to work with I load all the text boxes with the approiate data. I want to be able to determine if the user changed any of the content in any of the text boxes? I have looked at the text change event, but won't this event fire when I load the text boxes from the db? If any body has any suggestions or sample code for doing this it would be appreciated! Thanks! sk

    D N 2 Replies Last reply
    0
    • K kruegersck

      I have a form that has many text boxes on it. When the user selects a record to work with I load all the text boxes with the approiate data. I want to be able to determine if the user changed any of the content in any of the text boxes? I have looked at the text change event, but won't this event fire when I load the text boxes from the db? If any body has any suggestions or sample code for doing this it would be appreciated! Thanks! sk

      D Offline
      D Offline
      DaveyM69
      wrote on last edited by
      #2

      Two quick solutions. 0: Unsubscribe to the TextChanged events immediately prior to loading from the Database and add the subscribers again afterwards. 1. Use a boolean flag field that you set to true when loading and set to false afterwards. Check this flag in the TextChanged event handling method(s) and just return immediately if true.

      Dave
      BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
      Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)

      1 Reply Last reply
      0
      • K kruegersck

        I have a form that has many text boxes on it. When the user selects a record to work with I load all the text boxes with the approiate data. I want to be able to determine if the user changed any of the content in any of the text boxes? I have looked at the text change event, but won't this event fire when I load the text boxes from the db? If any body has any suggestions or sample code for doing this it would be appreciated! Thanks! sk

        N Offline
        N Offline
        Natza Mitzi
        wrote on last edited by
        #3

        I will vote for the boolean. Here is an example: private bool mInUpdate; private void LoadControlWithData() { //I want to keep the last mode bool lastUpdateMode = mInUpdate; try { mInUpdate = true; //Update code goes here } finally { //restore the last flag mInUpdate = lastUpdateMode; } } private void textBox1_TextChanged(....) { //Test the update flag if(!mInUpdate) { //Not in update lets do stuff } }

        Natza Mitzi

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups