We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Checking for changed integertextbox values

Hi, I have a series of Windows forms that have Next/Back buttons on them for navigation. I want to put in a check that makes prompts users to save their changes before proceeding to the next page. I''m getting tripped up with the IntegerTextBox. The property, Modified, always comes up false. I did see a property called "enterIntegerValue" that holds the original value. I could use this to compare with the current value, but can''t seem to get access to it. Any help? I''ve enclosed my checking routing below. private void CheckForModifications() { foreach( Control c in this.Controls) { if(c.GetType() == typeof(TextBox)) { TextBox txt = (TextBox)c; if (txt.Modified) { MessageBox.Show("Do you want to save your changes?"); } } if(c.GetType() == typeof(Syncfusion.Windows.Forms.Tools.IntegerTextBox)) { Syncfusion.Windows.Forms.Tools.IntegerTextBox inttxt = (Syncfusion.Windows.Forms.Tools.IntegerTextBox)c; if (inttxt.Modified) { MessageBox.Show("Do you want to save your changes?"); } } } }

4 Replies

AR Anupama Roy Syncfusion Team March 13, 2006 02:06 PM UTC

Hi jv, enterIntegerValue is not a property.Infact it is a variable which is declared as private and it is meant to save the current IntegerValue in Enter event so that it can be compared during validation.This is used for IntegerValueChanged and TextChanged event which will only be raised if the value is different during validation. I am looking into the modified property issue and will get back to you with more information soon. Also, please let me know the version you are having. Thank you for choosing Syncfusion products. Regards, Anu.


AR Anupama Roy Syncfusion Team March 13, 2006 02:30 PM UTC

Hi Jv, You can handle the Enter event as well as the Validated event inorder to get Modified property work in your scenario.Please take a look at the code snippet given below: private void integerTextBox1_Enter(object sender, System.EventArgs e) { initial= this.integerTextBox1.Text ; } private void integerTextBox1_Validated(object sender, System.EventArgs e) { if(initial!= this.integerTextBox1.Text) { this.integerTextBox1.Modified=true; } else { this.integerTextBox1.Modified=false; } } I am attaching a sample here.Please run this at your end and let me know if this helps you. Sample Thanks, Anu.


AD Administrator Syncfusion Team March 13, 2006 03:02 PM UTC

Anu, Thanks for the speedy reply. This looks like it will work fine. However, is there an easy way to incorporate this for all integer text boxes on the screen? I may have as many as 50(!) and would like to make this a default behavior for all of them. Thanks again. >Hi Jv, > >You can handle the Enter event as well as the Validated event inorder to get Modified property work in your scenario.Please take a look at the code snippet given below: > >private void integerTextBox1_Enter(object sender, System.EventArgs e) > { > initial= this.integerTextBox1.Text ; > } > > private void integerTextBox1_Validated(object sender, System.EventArgs e) > { > if(initial!= this.integerTextBox1.Text) > { > this.integerTextBox1.Modified=true; > } > else > { > this.integerTextBox1.Modified=false; > } > } > > > >I am attaching a sample here.Please run this at your end and let me know if this helps you. > >Sample > > >Thanks, > >Anu. >


AR Anupama Roy Syncfusion Team March 16, 2006 05:22 AM UTC

Hi Jv, I understand you difficulty.However,the right behaviour is to give a condition as I have given inorder to validate whether the text is modified or not. Microsoft defines this property like this : "Gets or sets a value that indicates that the text box control has been modified by the user since the control was created or its contents were last set" According to this,with the above code snippet you have given,even if the text is changed to same data ie for eg [the loaded value is 99,if you delete 99 and then again give the same number],IntegerTextBox will not ask for saving.However,TextBox will simply ask since we have not given any condition.I believe,the right behaviour of control in an application is to validate and give a message only when the Text is completely changed. Please let me know if you need furthur assistance. Thank you for your patience. Regards, Anu.

Loader.
Live Chat Icon For mobile
Up arrow icon