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

Text Selection

Thread ID:

Created:

Updated:

Platform:

Replies:

32962 Aug 10,2005 03:40 PM UTC Dec 2,2005 12:09 AM UTC WinForms 5
loading
Tags: EditControl
Dave French
Asked On August 10, 2005 03:40 PM UTC

Hi All, I am new to the edit control, so excuse my questions. I have some code that processes a script prior to it being displayed in the edit control, and if there is an issue with the code, I want to highlight the offending text after it is displayed. I have the index and length of the text, but I cant seem to find the appropriate method on the edit control to convert the raw text index into the edit controls position format. ‘ConvertOffsetToVirtualPosition’ doesn’t return the correct location, but the following will return the correct text. string temp = editControl.Text.Substring( index, length ); But, I want to get location of where the edit control has that text. I can parse the text myself, counting the number of new lines to count line number, etc, but I would rather avoid that if I can. Calling either of these methods doesn’t yield the correct location. Point virtualLoc = txt.ConvertOffsetToVirtualPosition( index ); Point physicalLoc = txt.ConvertVirtualPositionToPhysical( virtualLoc ); Second question, is there a way to have a portion of the document marked as read only? Thanks, Dave

Administrator [Syncfusion]
Replied On August 10, 2005 11:27 PM UTC

Hi Dave, 1. I confirm that the ConvertOffsetToVirtualPosition method works fine. Note that the origin for this virtual coordinate system is at (1,1) and not (0,0). I have attached a test sample here that illustrates how you could highlight the offending code in wavy red underlines. Presently the EditControl does not have any APIs to specify a TextRange in terms of VirualPoints. We will add this feature shortly. Till then, you could use the following workaround : Set the offending section as the selected text using the SetSelection method, underline this selected TextRange and then reset selection using the ResetSelection method as shown in code below : // Starting offset converted to virtual point Point pt1 = this.editControl1.ConvertOffsetToVirtualPosition(8); // Ending offset converted to virtual point Point pt2 = this.editControl1.ConvertOffsetToVirtualPosition(13); this.editControl1.SetSelection(pt1.X, pt1.Y, pt2.X, pt2.Y); ISnippetFormat format = editControl1.RegisterUnderlineFormat(Color.Red, UnderlineStyle.Wave, UnderlineWeight.Thick); this.editControl1.SetUnderline (this.editControl1.Selection.Top, this.editControl1.Selection.Bottom, format); this.editControl1.ResetSelection(); Please refer to the sample and let me know if this meets your requirements. 2. I am afraid, this functionality does not exist in the current implementation of the EditControl. However, we have considered this as a feature request and will try our best to implement this as soon as possible. You could track the progress of this feature request at this link below : Feature Request #345 - Ability to set certain sections of text in the EditControl as read only We appreciate your patience, and thanks for your continued interest in Syncfusion products. Regards, Guru Patwal Syncfusion, Inc.

Dave French
Replied On August 17, 2005 02:00 PM UTC

Hi Guru, Thanks for the quick reply, and sorry for the delay in getting back to you. This might be an odd question, but I don’t have the ‘SetSelection’ method on the edit control. The sample that you sent doesn’t compile on my machine using the binaries I have, becuase that method doesnt exist, its the only compile error i get. error CS0117: ''Syncfusion.Windows.Forms.Edit.EditControl'' does not contain a definition for ''SetSelection'' Version: - The folder on the hard drive lists: - 3.2.1.0 - The version of the Syncfusion.Edit.Windows.dll in the “Program Files\Syncfusion\Essential Studio\Assemblies\1.1” directory is: - 3.201.1.0 Does the version I have not include this method? Thanks, Dave

Administrator [Syncfusion]
Replied On August 17, 2005 11:19 PM UTC

Hi Dave, Thanks for the response. The SetSelection method and several other features/fixes were introduced after v3.2.1.0 release which are now available in v3.3 RC. I have created a Direct-Trac incident 20478 in this regard, and have updated you with the necessary download information. Please refer to my response and let me know if you need any other information. We appreciate your continued interest in Syncfusion products. Regards, Guru Patwal Syncfusion, Inc.

Administrator [Syncfusion]
Replied On August 19, 2005 12:03 AM UTC

Hi Dave, The APIs for interconversion between Offsets and CoordinatePoints have been added. Now you could highlight offending code in your application as shown in code below : // 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); ISnippetFormat format = editControl1.RegisterUnderlineFormat(Color.Red, UnderlineStyle.Wave, UnderlineWeight.Thick); this.editControl1.SetUnderline (cpt1, cpt2, format); Let me know if you need any other information. Regards, Guru Patwal Syncfusion, Inc.

Administrator [Syncfusion]
Replied On December 2, 2005 12:09 AM UTC

Hi Dave, Feature 345 has been implemented internally and will be available in the next release of Essential Edit. We appreciate your patience and thanks for your continued interest in Syncfusion products. Regards, Guru Patwal Syncfusion, Inc.

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

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

;