TX Text Control .NET for Windows Forms

What's New in TX Text Control .NET for Windows Forms 30.0

Topic

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

AreaWhat is new
CommentsComments and replies compatible with MS Word, with events, a comments sidebar, a ribbon group and a comments dialog
Dialog boxesModeless dialog boxes for comments and tracked changes, new character attributes in the font and style dialogs
FormattingAutomatic sub- and superscript, capitals and small capitals, character spacing and scaling, the culture of a style
Images and framesSVG images, colored single or double borders for text frames
Mail mergeMerging 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 CommentedText object, 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. TextControl raises 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 events CommentCreated and CommentDeleted as 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

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 Superscript and Subscript, the value SuperscriptUpperEdge doesn't extend above capital letters, and SubscriptBaseline scales 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: PetiteCapitals have the height of a lowercase x, and SmallCapitals are 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; null means 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. With Preselect, their content is preselected with the data, and the document remains a form. With Replace, 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.

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 LoadEmbeddedFiles is 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 value LoadEmbeddedData.
  • .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