)
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: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to dynamically validate text using the TextChanged event in the WinForms SyntaxEditor (EditControl)?

Platform: WinForms |
Control: EditControl |
Published Date: April 30, 2011 |
Last Revised Date: December 13, 2019

Validation

This can be easily accomplished using the TextChanged event and a timer. The validation routine is invoked in response to a brief pause in typing by the user. Refer the below code snippets.

C#

private void editControl1_TextChanged(object sender, System.EventArgs e)
{
   // Do not start the timer as long as characters are being typed.
   if (this.timer1.Enabled == true)
   {
       this.timer1.Stop();
       this.timer1.Start();
   }
}
private void timer1_Tick(object sender, System.EventArgs e)
{
       this.ValidateText();
       this.timer1.Stop();
}
private void ValidateText()
{
       // Perform your validation logic here.
       Console.WriteLine("Text validated");
}

 

VB

Private Sub editControl1_TextChanged(sender As Object, e As System.EventArgs) Handles
editControl1.TextChanged
    ' Do not start the timer as long as characters are being typed.
    If Me.timer1.Enabled = True Then
        Me.timer1.Stop()
    End If
    Me.timer1.Start()
End Sub 'editControl1_TextChanged
Private Sub timer1_Tick(sender As Object, e As System.EventArgs) Handles timer1.Tick
    Me.ValidateText()
    Me.timer1.Stop()
End Sub 'timer1_Tick
Private Sub ValidateText()
    ' Perform your validation logic here.
    MessageBox.Show("Text validated")
End Sub 'ValidateText

 

Reference link: https://help.syncfusion.com/windowsforms/syntax-editor/events#text-events

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

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

Live Chat Icon For mobile
Live Chat Icon