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. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Checking for changed integertextbox values

Thread ID:

Created:

Updated:

Platform:

Replies:

41797 Mar 12,2006 03:19 PM UTC Mar 16,2006 05:22 AM UTC WinForms 4
loading
Tags: Tools
Administrator [Syncfusion]
Asked On March 12, 2006 03:19 PM UTC

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?"); } } } }

Anupama Roy [Syncfusion]
Replied On 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.

Anupama Roy [Syncfusion]
Replied On 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.

Administrator [Syncfusion]
Replied On 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. >

Anupama Roy [Syncfusion]
Replied On 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.

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;