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

Edit control content changed twice

Hello, I am using an edit control, and I need to check the content of the control whenever there is a change in content. However, when I change the content of the control through code, the ContentChanged event is fired twice: first with the current content in e.Content, then with the correct text in e.Content. Am I doing something wrong? Thanks. Raymond.

3 Replies

AD Administrator Syncfusion Team March 26, 2004 08:40 PM UTC

Hi Raymond Here is a sample created by modifying the EmbeddedInFile sample that ships with Essential Edit (version 2.0.3.0) to reproduce this issue. Pressing Button1 appends some text to the Edit Control and ContentChanged is called only once. Can you modify this sample to reproduce the problem so that we can take a look? Regards Arun


AD Administrator Syncfusion Team March 29, 2004 06:21 PM UTC

Hi Arun, I am using this.editControl1.Text = "Hellow"; to change the text (because it is at initialization). If you change this line: this.editControl1.AppendText("Test"); to this.editControl1.Text = "Hellow"; in the button1_click event, you''ll get 2 content_changed event. Thanks. Raymond >Hi Raymond > >Here is a sample created by modifying the EmbeddedInFile sample that ships with Essential Edit (version 2.0.3.0) to reproduce this issue. Pressing Button1 appends some text to the Edit Control and ContentChanged is called only once. > >Can you modify this sample to reproduce the problem so that we can take a look? > >Regards >Arun >


AD Administrator Syncfusion Team March 31, 2004 01:06 PM UTC

Hi Raymond, That is the correct and intented behavior as when you call: this.editControl1.Text = "Hello"; the EditControl first clears the existing text and then adds the new text. To understand this better modify the earlier sample by adding: private void editControl1_ContentChanged(object sender, Syncfusion.Windows.Forms.Edit.ContentChangedEventArgs e) { MessageBox.Show("e.text=" + e.Text + "editControl1.Text=" + this.editControl1.Text); } private void button1_Click(object sender, System.EventArgs e) { this.editControl1.Text = "Hello"; } When you press button1, you will see that the first time ContentChanged is called the Editcontrol''s text is cleared and e.Text contains the text that is being removed. The second time ContentChanged is called e.text has the text that will be the text of the EditControl. Hope this explanation clears any doubts you may have with this behavior. Do let us know if you have any further questions. Regards Arun

Loader.
Live Chat Icon For mobile
Up arrow icon