What's New in TX Text Control .NET for Windows Forms 30.0
Version 30.0 gave TX Text Control .NET for Windows Forms comments that MS Word reads, together with a sidebar, a ribbon group and a dialog box to work with them. Its other additions over version 29.0 reach from typographic character attributes and SVG images to a mail merge that fills form fields.
Version 30.0 was released in November 2021, together with TX Text Control .NET Server, TX Text Control .NET for WPF, TX Text Control ActiveX and TX Spell .NET 9.0. Version 29.0 was sold as TX Text Control X19; from version 30.0 on, the product is named after its version number. The current version is Version 34.0, and the service packs of 30.0 are listed on Service Packs.
Version 30.0 at a Glance
| Area | What is new |
|---|---|
| Comments | Comments and replies compatible with MS Word, with events, a comments sidebar, a ribbon group and a comments dialog |
| Dialog boxes | Modeless dialog boxes for comments and tracked changes, new character attributes in the font and style dialogs |
| Formatting | Automatic sub- and superscript, capitals and small capitals, character spacing and scaling, the culture of a style |
| Images and frames | SVG images, colored single or double borders for text frames |
| Mail merge | Merging data into form fields |
Comments
A comment is a note attached to a piece of text. Users select text and open a comment input control from the context menu; the comment is added when they close the control with a mouse click or the Enter key. The commented text is highlighted in a color that depends on the user. The context menu of a comment changes or removes it, or adds a reply.
- Comments and replies. All comments of a text part are CommentedText objects in a CommentCollection. Each one has the Comment itself, a CreationTime and a UserName. A reply is linked to its comment through Replies and RepliedComment. When you remove a comment, its replies are removed as well.
- Where comments are. TextControl.Comments contains the comments of the text part that has the input focus. Headers, footers and text frames have their own collections: HeaderFooter.Comments, TextFrame.Comments and IFormattedText.Comments.
- Add comments. CommentCollection.Add without a parameter opens the comment input control for the user. With a
CommentedTextobject, it adds a prepared comment. Both return a CommentCollection.AddResult value. - Work with a comment. EditComment and ReplyToComment open the input control for the user, and Select and ScrollTo select the commented text and scroll it into view.
- Number, color and content. Number is the number of a comment in the text flow, starting at 1 for the first comment of the document. The static DefaultHighlightColor is the highlight color used when the author is unknown; comments of the current user are highlighted in red. Save saves the commented text to a byte array or a string in the format you pass.
- Authors. A new comment gets the first name of TextControl.UserNames as its author. If the list is empty, the author is unknown.
- Highlighting. TextControl.CommentHighlightMode sets whether commented text is highlighted when it contains the input position (the default), always or never. TextControl.EditableRegionHighlightMode does the same for editable regions.
- File formats. Comments are saved and loaded with the TX Text Control format, RTF, DOC and DOCX.
- Tracked changes. A comment can be attached to a tracked change. It is removed when the change is accepted or rejected.
- Events.
TextControlraises six comment events, when a comment is created, deleted or changed, when the input position enters or leaves commented text and when a comment is activated or deactivated. ServerTextControl has the comment collection and the eventsCommentCreatedandCommentDeletedas well.
Comments shows how to add, answer, edit and remove comments in code and how to handle their events. The blog article Sneak Peek 30.0: MS Word Compatible Comments shows the comments in the user interface.
Comments in the User Interface
- Comments sidebar. A Sidebar lists the comments of the document when you connect it to the ribbon's proofing tab with RibbonProofingTab.CommentsSidebar for a vertical sidebar or CommentsHorizontalSidebar for a horizontal one. Without the ribbon, set Sidebar.ContentLayout to
SidebarContentLayout.Commentsand connect the sidebar with Sidebar.TextControl. See Sidebar. - Ribbon group. The Proofing tab has a group that adds, deletes, edits and navigates comments, shows them and opens the comments sidebar. Its items are values of RibbonProofingTab.RibbonItem, such as
TXITEM_AddCommentandTXITEM_NextComment. - Comments dialog. CommentsDialog is a modeless dialog box that lists all comments, in which users delete, reply to or edit them. CommentsDialog.FindItem returns the control of the dialog box that a CommentsDialog.DialogItem value identifies.
- Tracked changes dialog. TrackedChangesDialog is a modeless dialog box that lists all tracked changes, in which users accept or reject them. TrackedChangesDialog.FindItem returns one of its controls by a TrackedChangesDialog.DialogItem value. See Track Changes.
Character Attributes and Styles
Version 30.0 adds character attributes for typographic details such as diagonal fractions and ordinal indicators. The font dialog shows them on a new Position and Effects tab.
- Automatic sub- and superscript. Selection.AutoBaseline scales the font and moves the text above or below the baseline, with the values the font defines. If the font defines none, the text is scaled to 50% and moved 40% above or 15% below the baseline. Besides
SuperscriptandSubscript, the valueSuperscriptUpperEdgedoesn't extend above capital letters, andSubscriptBaselinescales the text without moving it below the baseline, for example for the numerator and denominator of a diagonal fraction. - Capitals. Selection.Capitals shows lowercase letters as capitals of the same size (
Capitals) or as smaller capitals:PetiteCapitalshave the height of a lowercase x, andSmallCapitalsare 10% higher. - Spacing and scaling. Selection.CharacterSpacing adds a fixed value in twips to each character; a negative value reduces the spacing. Selection.CharacterScaling sets the character width in percent of the average character width.
- Change the capitalization. Selection.ChangeCapitalization converts the selected text with a CapitalizationSettings value: to upper or lower case, each word or sentence capitalized, or the case toggled.
- Formatting styles. The new attributes are also properties of FormattingStyle, and all text filters load and save them. FormattingStyle.Culture sets the language of a character or paragraph style, which is used for spell checking and hyphenation;
nullmeans the neutral culture. The formatting style dialog shows the new attributes and the culture.
The blog article Sneak Peek Version 30.0: Extended Character Attributes shows examples of each attribute. See also Text and Paragraph Formatting.
SVG Images
Documents can contain images in the Scalable Vector Graphics format (SVG), with all the formatting options of other images. When a document is saved as PDF, SVG images are converted to PDF vector graphics.
The SVG support is based on W3C SVG 1.1 (Second Edition). References to external images or style sheets, interactivity and animation, advanced text transformations, patterns, masking, compositing and filter effects aren't supported. Supported File Formats lists all image formats, and the blog article TX Text Control 30.0 Preview: Inserting SVG Images inserts SVG images in code.
Text Frames
The border of a text frame can have a color, set with TextFrame.BorderColor, and can be a single or double line, set with TextFrame.BorderStyle and the values of FrameStyle. Users set both in the text frame dialog, which TextFrameAttributesDialog opens, and on the Frame Formatting tab of the ribbon, the RibbonFrameLayoutTab.
The text frame dialog and the ribbon group of the Frame Formatting tab also gained controls for the other settings of a frame's appearance, which the API already had: the background color (BackColor), the transparency (Transparency), the width of the border line (BorderWidth) and the distances between the border and the text (InternalMargins).
Mail Merge
MailMerge creates documents from a template and data. In version 30.0, it can merge data into form fields, the fields that users fill out in a document form.
- Form field merge type. MailMerge.FormFieldMergeType decides what happens to form fields. With
None, the default, they aren't merged. WithPreselect, their content is preselected with the data, and the document remains a form. WithReplace, they are replaced with the data, and empty fields are removed according to RemoveEmptyFields. - FormFieldMerged event. FormFieldMerged occurs when a form field has been merged. Its FormFieldMergedEventArgs contain the form field, the data row, whether the field has been merged and, if the field is in a merge block or a table, the block and the table cell.
- Inserted merge blocks. MergeBlockSettings.AddResult tells whether a merge block has been inserted, and InsertMergeBlockDialog.AddResult does the same for the dialog box in which users insert one.
Merge fields and form fields can be merged in the same run. The blog article Merging Form Fields using the MailMerge Class shows both merge types.
New Classes and Members
The What's New documentation of version 30.0 lists these classes, properties, methods and events as new in TX Text Control .NET for Windows Forms. They are grouped by class, and each name leads to its reference page. The list of the documentation also names members of Selection that existed before version 30.0, such as Bold, FontName and Text, and they are left out here.
- CommentCollection (new class): Add, CopyTo, Count, GetEnumerator, GetItem, IsSynchronized, Item, Remove, SyncRoot
- CommentedText (new class): Active, Comment, CreationTime, DefaultHighlightColor, EditComment, HighlightColor, HighlightMode, ID, Length, Number, RepliedComment, Replies, ReplyToComment, Save, ScrollTo, Select, Start, Text, UserName
- CommentEventArgs (new class): CommentedText
- CommentsDialog (new class): FindItem
- DocumentServer.DataSources.MergeBlockSettings: AddResult
- DocumentServer.MailMerge: FormFieldMerged, FormFieldMergeType
- DocumentServer.MailMerge.FormFieldMergedEventArgs (new class): DataRow, FormField, MergeBlockName, Merged, NestingDepth, TableCell
- DocumentServer.Windows.Forms.InsertMergeBlockDialog: AddResult
- FormattingStyle: AutoBaseline, Capitals, CharacterScaling, CharacterSpacing, Culture
- HeaderFooter: Comments
- IFormattedText: Comments
- Selection: AutoBaseline, Capitals, ChangeCapitalization, CharacterScaling, CharacterSpacing
- ServerTextControl: CommentCreated, CommentDeleted, Comments, OnCommentCreated, OnCommentDeleted
- TextControl: CommentChanged, CommentCreated, CommentDeleted, CommentedTextEntered, CommentedTextLeft, CommentHighlightMode, Comments, CommentStateChanged, EditableRegionHighlightMode, OnCommentChanged, OnCommentCreated, OnCommentDeleted, OnCommentedTextEntered, OnCommentedTextLeft, OnCommentStateChanged
- TextFrame: BorderColor, BorderStyle, Comments
- TrackedChangesDialog (new class): FindItem
- Windows.Forms.Ribbon.RibbonProofingTab: CommentsHorizontalSidebar, CommentsSidebar
Upgrade to Version 30.0
- Update notes. The update notes of version 30.0 list one entry: LoadSettings.PDFImportSettings was extended with settings for the data that a PDF document carries besides its text. Of the three names the notes give, only
LoadEmbeddedFilesis a value of the current PDFImportSettings enumeration; it provides the files embedded in the document. The metadata, the form fields and the text coordinates come from the valueLoadEmbeddedData. - .NET versions. Version 30.0 supports the .NET Framework 4.8, .NET 5 and .NET 6. The blog article Migrate a Windows Forms Desktop Application to .NET 6 moves an application of that time to .NET 6. NuGet packages and full designer support for .NET followed in Version 31.0.
- Licensing. The setup no longer registers the assemblies in the global assembly cache (GAC). As a result, every entry in licenses.licx needs the full version number of the assembly. Breaking Changes in the Upgrade Guide shows the entry, and the blog article Version 30.0: Changes in Licenses.licx explains the change.
Next Steps
- Version 31.0: the features of the next version.
- Version 29.0: the version before, and the Older Versions back to 10.1.
- Breaking Changes: the changes that can require work when you upgrade.
- Comments: work with comments in the editor.
- TX Text Control 30.0 and TX Spell .NET 9.0 Have Been Released: the release announcement on the Text Control Blog.