This is a migrated thread and some comments may be shown as answers.

Command Examples?

2 Answers 111 Views
SyntaxEditor
This is a migrated thread and some comments may be shown as answers.
Jason
Top achievements
Rank 1
Veteran
Jason asked on 26 Jul 2020, 07:36 AM

Could you provide an example of using the RadSyntaxEditor commands? 

 

https://docs.telerik.com/devtools/winforms/controls/syntax-editor/commands

Thanks! Jason

2 Answers, 1 is accepted

Sort by
0
Accepted
Nadya | Tech Support Engineer
Telerik team
answered on 28 Jul 2020, 03:10 PM

Hello, Jason,

Please refer to the following example that demonstrates how you can use the commands in RadSyntaxEditor. You should just choose the desired command through the Commands property of the control, then call the Execute method.

The following example demonstrates how to select and delete the occurrence of the "Telerik" word from the loaded text in the code-behind together with undo and redo buttons:

public RadForm1()
{
    InitializeComponent();

    using (StreamReader reader = new StreamReader("../../CS_File.txt"))
    {
        this.radSyntaxEditor1.Document = new TextDocument(reader);
    }

    var xmlTragger = new XmlTagger(this.radSyntaxEditor1.SyntaxEditorElement);
    this.radSyntaxEditor1.TaggersRegistry.RegisterTagger(xmlTragger);

    var xmlFolding = new XmlFoldingTagger(this.radSyntaxEditor1.SyntaxEditorElement);
    this.radSyntaxEditor1.TaggersRegistry.RegisterTagger(xmlFolding);
}

private void radButton1_Click(object sender, EventArgs e)
{
    this.radSyntaxEditor1.Commands.NavigateNextMatchCommand.Execute("Telerik");
    this.radSyntaxEditor1.Commands.DeleteCommand.Execute(null);
}

private void radButton2_Click(object sender, EventArgs e)
{
    this.radSyntaxEditor1.Commands.UndoCommand.Execute(null);
}

private void radButton3_Click(object sender, EventArgs e)
{
    this.radSyntaxEditor1.Commands.RedoCommand.Execute(null);
}

I hope this helps. Let me know if you have further questions.

Regards,
Nadya
Progress Telerik

0
Jason
Top achievements
Rank 1
Veteran
answered on 06 Aug 2020, 02:41 PM
Perfect. Thanks! 
Tags
SyntaxEditor
Asked by
Jason
Top achievements
Rank 1
Veteran
Answers by
Nadya | Tech Support Engineer
Telerik team
Jason
Top achievements
Rank 1
Veteran
Share this question
or