)
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 implement the strikethrough feature in the WinForms SyntaxEditor (EditControl)?

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

Strikethrough

The below code illustrates the strikethrough feature to strike through the current line, the selected text and a range of text in the EditControl. This is a useful feature in denoting text that was deleted from the original document or highlighting offending code or unwanted text. The strikethrough color can be varied by varying the arguments in the StrikeThrough method.

C#

private void menuItem1_Click(object sender, System.EventArgs e)
{
   // Strike out the current line
   this.editControl1.StrikeThrough(this.editControl1.CurrentLine, Color.IndianRed);
}
private void menuItem2_Click(object sender, System.EventArgs e)
{
   // Strike out the selected text
   this.editControl1.StrikeThrough(this.editControl1.Selection.Top, this.editControl1.Selection.Bottom, Color.Navy);
}
private void menuItem3_Click(object sender, System.EventArgs e)
{
   int startOffsetValue = 100;
   int endOffsetValue = 240;
   // Starting offset converted to virtual point
   Point startVirtualPoint = this.editControl1.ConvertOffsetToVirtualPosition(startOffsetValue);
   // Ending offset converted to virtual point
   Point endVirtualPoint = this.editControl1.ConvertOffsetToVirtualPosition(endOffsetValue);
   // Converting the VirtualPoints to ParsePoints
   ParsePoint startParsePoint = new ParsePoint(startVirtualPoint.Y, startVirtualPoint.X, 0);
   ParsePoint endParsePoint = new ParsePoint(endVirtualPoint.Y, endVirtualPoint.X, 0);
   // Creating the associated CoordinatePoints that indicate the text range
   CoordinatePoint startCoordinatePoint = new CoordinatePoint((ILexemParser)this.editControl1.Parser,    startParsePoint, startVirtualPoint.Y, startVirtualPoint.X, true);
   CoordinatePoint endCoordinatePoint = new CoordinatePoint((ILexemParser)this.editControl1.Parser, endParsePoint, endVirtualPoint.Y, endVirtualPoint.X, true);
   // Strike out the text in the specified text range
   this.editControl1.StrikeThrough(startCoordinatePoint, endCoordinatePoint, Color.Brown);
}

 

VB

Private Sub menuItem1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles menuItem1.Click
   ' Strike out the current line
   Me.editControl1.StrikeThrough(Me.editControl1.CurrentLine, Color.IndianRed)
End Sub 'menuItem1_Click
Private Sub menuItem2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles menuItem2.Click
   ' Strike out the selected text
   Me.editControl1.StrikeThrough(Me.editControl1.Selection.Top, Me.editControl1.Selection.Bottom, Color.Navy)
End Sub 'menuItem2_Click
Private Sub menuItem3_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles menuItem3.Click
   Dim startOffsetValue As Integer = 100
   Dim endOffsetValue As Integer = 240
   ' Starting offset converted to virtual point
   Dim startVirtualPoint As System.Drawing.Point =    Me.editControl1.ConvertOffsetToVirtualPosition(startOffsetValue)
   ' Ending offset converted to virtual point
   Dim endVirtualPoint As System.Drawing.Point = Me.editControl1.ConvertOffsetToVirtualPosition(endOffsetValue)
   ' Converting the VirtualPoints to ParsePoints
   Dim startParsePoint As New ParsePoint(startVirtualPoint.Y, startVirtualPoint.X, 0)
   Dim endParsePoint As New ParsePoint(endVirtualPoint.Y, endVirtualPoint.X, 0)
   ' Creating the associated CoordinatePoints that indicate the text range
   Dim startCoordinatePoint As New CoordinatePoint(CType(Me.editControl1.Parser, ILexemParser), startParsePoint, startVirtualPoint.Y, startVirtualPoint.X, True)
   Dim endCoordinatePoint As New CoordinatePoint(CType(Me.editControl1.Parser, ILexemParser), endParsePoint, endVirtualPoint.Y, endVirtualPoint.X, True)
   ' Strike out the text in the specified text range
   Me.editControl1.StrikeThrough(startCoordinatePoint, endCoordinatePoint, Color.Aqua)
End Sub 'menuItem3_Click

 

Reference link: https://help.syncfusion.com/windowsforms/syntax-editor/text-visualization#strike-out

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