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.
Unfortunately, activation email could not send to your email. Please try again.

How do I implement the strikethrough feature in the EditControl?

 

This sample illustrates the strikethrough feature to strike through the current line, the selected text and a range of text in the EditControl. This is an 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.

Refer to the code snippets and the sample attached to know more about it.

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

Article ID: Published Date: Last Revised Date: Platform: Control:
354 04/30/2011 07/10/2014 Windows Forms EditControl
Tags:
Did you find this information helpful?
Add Comment
You must log in to leave a comment

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.