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

How to implement VS.NET like XML tag insertion feature using WinForms SyntaxEditor (EditControl)?

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

Text handling

This can be used, while editing the XML language tags in the SyntaxEditor (EditControl).

The cursor can be placed at any positon of the line and the nodes will be inserted correctly in the beginning and the end of the current line. This feature saves time while editing your XML documents using the Essential Edit. Refer to the code attached to know more about it.

C#

private void menuItem_Click(object sender, System.EventArgs e)
{
    this.inputDialog.ShowDialog();
    if(this.accepted == true)
    {
        if(this.inputString.Equals(""))
        {
            MessageBox.Show("The node name cannot be empty");
        }
        else
        {
            this.editControl1.MoveToLineStart();
            this.editControl1.InsertText(this.editControl1.CurrentLine,(this.editControl1.CurrentColumn)," ");
            this.editControl1.InsertTexthis.editControl1.CurrentLine,this.editControl1.CurrentColumn, "<"+this.inputString+">");
            this.editControl1.InsertText(this.editControl1.CurrentLine,(this.editControl1.CurrentColumn)," ");
            this.editControl1.AppendText("</"+this.inputString+">");
        }
    }
}

 

VB

Private Sub menuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles menuItem12.Click
     Me.inputDialog.ShowDialog()
     If Me.accepted = True Then
         If Me.inputString.Equals("") Then
             MessageBox.Show("The node name cannot be empty")
         Else
             Me.editControl1.MoveToLineStart()
             Me.editControl1.InsertText(Me.editControl1.CurrentLine,(Me.editControl1.CurrentColumn)," ")
             Me.editControl1.InsertText(Me.editControl1.CurrentLine,Me.editControl1.CurrentColumn, "<"+Me.inputString+">")
             Me.editControl1.InsertText(Me.editControl1.CurrentLine,(Me.editControl1.CurrentColumn)," ")
             Me.editControl1.AppendText("</"+Me.inputString+">")
         End If
     End If
End Sub

 

Reference link: https://help.syncfusion.com/windowsforms/syntaxeditor/editing#text-handling

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