I would like to be able to set the default action to single line spacing. I have found some code as follows that allows you to change the line spacing of a selection. This code wont work in my case because when the text editor is loaded there is no initial selection.
ParagraphSettings paragraphSettings = new ParagraphSettings();
ParagraphSpacingSettings paragraphSpacingSettings = new ParagraphSpacingSettings();
paragraphSettings.WordWrap = true;
paragraphSettings.Spacing = paragraphSpacingSettings;
paragraphSpacingSettings.LineSpacing = new LineSpacing(1);
string error;
_textEditor.Document.ApplyParagraphSettings(_textEditor.Selection.DocumentSpan, paragraphSettings, out error);
Hello Aaron,
When the editor is loaded with a new empty document or new paragraphs are added to some document the settings applied on the new content are the Document’s default settings. In order to apply LineSpacing of 1 line for all paragraphs in the document you need to set these spacing settings to the default ParagraphSettings of the RootNode’s DocumentSettings object as follows:
Editor.Document.RootNode.Settings = new DocumentSettings();
Editor.Document.RootNode.Settings.DefaultParagraphSettings = paragraphSettings;
In the attached sample application I’m using this approach to achieve your requirements.
Please, let me know if you need further assistance on the matter.
Using the attached solution with infragistics 14.2 dlls, it still has a double line spacing when typing and the only way to get single line spacing is to hold shift while pressing enter. Could it be a issue w/ the version of infragistics I am using?
Setting the LineSpacing would affect only the spacing between all lines belonging to a single paragraph but it would have no effect to the spacing following the last line of that paragraph. By simply hitting Enter key the user creates a new paragraph, while by using Shift + Enter the new lines are added to the same paragraph hence the difference in the spacing you noticed. What I can suggest is decreasing the AfterParagraph vertical spacing which by default is 13.333 pixels.
In the sample application I provided you can achieve this by adding the following line of code:
paragraphSpacingSettings.AfterParagraph = new ParagraphVerticalSpacing(1);
I am just checking if my last response was helpful and you managed to resolve your issue. If you require any further assistance, please, do not hesitate to contact us.
Sorry for the late reply, I got sent on some other projects and just came back to this one. I am using 14.2 and used the following code in your sample project however it still produces a extra space when I press enter. Should I update to a newer version?
Regards,
Aaron
string errors = string.Empty;
InitializeComponent();
RTE.HiddenSymbolDisplayMode = Infragistics.Controls.Editors.HiddenSymbolDisplayMode.DisplayAllHiddenSymbols;
paragraphSpacingSettings.AfterParagraph = new ParagraphVerticalSpacing(new Extent(1,ExtentUnitType.LogicalPixels));
RTE.Document.RootNode.Settings = new DocumentSettings();
RTE.Document.RootNode.Settings.DefaultParagraphSettings = paragraphSettings;
Thank you for following up. The issue you are experiencing has been fixed in the latest service release for 14.2 (14.2.20142.2224). It can be downloaded from our web site at the following link:
https://ko.infragistics.com/my-account/keys-and-downloads