Set Tab Size in Editor

SyntaxEditor for Windows Forms Forum

Posted 18 years ago by Barry Ahrens - Member of Technical Staff, Teledyne Scientific
Avatar
The default tab size for the syntax editor seems to be 4 spaces.

Is there an easy way to change the tab size at run time?

Thanks very much!

Comments (8)

Posted 18 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Sure, it's this property:
editor.Document.SpacesInTab


Actipro Software Support

Posted 4 years ago by JP Garza
Avatar

Is there a way to change Document.SpacesInTab (now Document.TabSize) in an MVVM fashion?

[Modified 4 years ago]

Posted 4 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Probably not via XAML since the document objects are plain old CLR objects and not DependencyObjects.  You could create the document class in your view-model though and bind it to the SyntaxEditor.Document property.


Actipro Software Support

Posted 4 years ago by JP Garza
Avatar

That works, but that is afecting my selected DocumentItem Text field in my List<DocumentItem>. Now all DocumentItems have the same text when binding the SyntaxEditor's Document to an EditorDocumnet item.

I do not want the EditorDocument to affect the SyntaxEditor Text since the Text is binded to the currently selected Tab/DocumentItem Text prperty.

[Modified 4 years ago]

Posted 4 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

If you configure it right, you shouldn't have any problems.  Each EditorDocument maintains its own text structure, and each SyntaxEditor can reference one EditorDocument (via SyntaxEditor.Document) at a time.  Edits made in SyntaxEditor will only update the single EditorDocument that is loaded in it.  If you are binding to the SyntaxEditor.Text property, then that is updating the EditorDocument as well.  Make sure you bind the document in before binding the Text property.  You should be able to do that by setting the Document property prior to the Text property in XAML.

And yes, updating the SyntaxEditor.Document property will update the SyntaxEditor text since the text being edited is what is in the document.  SyntaxEditor does not edit text separately from what is in the document.


Actipro Software Support

Posted 4 years ago by JP Garza
Avatar

Hello thanks for the reply.

I am indeed setting the Document property prior to the Test in XAML.

The issue occurs when I try to switch tabs. The newly selected tab will grab the value of the previous selected tab. 

Every docking tab of mine contains a different SyntaxEditor and every SyntaxEditor has its own DocumentItem. Currently I have one EditorDocument in the parent ViewModel that is shared among all SyntaxEditors. Therefore, I think what you are saying is that every SyntaxEditor should have its own EditorDocument right?

Posted 4 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Correct, the EditorDocument is what stores the text for a document being edited.  Therefore the only time you would ever want to have a single EditorDocument instance shared among multiple SyntaxEditors is if you want to edit the same document text in multiple different SyntaxEditor instances.  This would be done in a situation like in VS where you create a New Window for a document, so there are now two tabs with editors editing the same document.

In all other situations, each SyntaxEditor should have its own distinct EditorDocument.


Actipro Software Support

Posted 4 years ago by JP Garza
Avatar

Thank you! I followed your suggestion and it worked.

Just had to make the EditorDocument part of my DocumentItem object. This way every tab/SyntaxEditor has its own EditorDocument.

[Modified 4 years ago]

The latest build of this product (v24.1.0) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.