Newbie Question
-
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
-
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
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) -
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
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