TX Text Control .NET for Windows Forms Data Binding
The new WPF version of TX Text Control comes with new data binding possibilities. But Windows Forms offers a similar way of binding properties to data sources or other properties. But the binding is not added in XAML (which is a concept of WPF), but the code itself. But the advantage is still valid: The presentation layer can be abstracted and no additional event handling is required to update the state of specific buttons or menu entries. The TextControl.InputFormat class is available in…

The new WPF version of TX Text Control comes with new data binding possibilities. But Windows Forms offers a similar way of binding properties to data sources or other properties. But the binding is not added in XAML (which is a concept of WPF), but the code itself. But the advantage is still valid: The presentation layer can be abstracted and no additional event handling is required to update the state of specific buttons or menu entries.
The TextControl.InputFormat class is available in the Windows Forms version as well. The properties of this class can be bound to other controls.
The following code shows how to bind a CheckBox that is displayed as a toggle button to the Bold property of the TextControl.InputFormat class:
checkBox1.DataBindings.Add("Checked",
textControl1.InputFormat,
"Bold",
true,
DataSourceUpdateMode.OnPropertyChanged);

But what about a ComboBox that should list all available fonts, display the font at the current input position and apply a new font to the selection when the user selects another font in the ComboBox?
First, we can bind the DataSource property of the ComboBox to the GetSupportedFonts method of TX Text Control. This method returns all supported fonts that can be actually used in the document. The Text property of the ComboBox can be bound to the FontFamily property of the TextControl.InputFormat class. And that is all you need to connect the ComboBox to TX Text Control. No event handling, no Selection class.
comboBox1.DataSource = textControl1.GetSupportedFonts();
comboBox1.DataBindings.Add("Text",
textControl1.InputFormat,
"FontFamily",
true,
DataSourceUpdateMode.OnPropertyChanged);
Related Posts
TX Text Control 33.0 SP3 is Now Available: What's New in the Latest Version
TX Text Control 33.0 Service Pack 3 is now available, offering important updates and bug fixes for all platforms. If you use TX Text Control in your document processing applications, this service…
ASP.NETASP.NET CoreDocument Viewer
High-Performance Text Replacement in Large DOCX Files using C# .NET
Learn how to efficiently replace text in large DOCX files using C# .NET and the ServerTextControl component from Text Control. This article demonstrates the performance benefits of using the…
ASP.NETASP.NET CoreDocument Viewer
Document Viewer 33.2.1 Released: New Event and Bug Fixes
This service pack includes important bug fixes and improvements to enhance the stability and performance of the Document Viewer. In addition, a new event has been introduced to provide developers…
ASP.NETAccessibilityASP.NET Core
Upcoming Support for PDF/UA Compliance and Tagged PDF Generation in Version 34.0
We are happy to announce that version 34.0 will support PDF/UA compliance and the creation of tagged PDF documents. This significant update demonstrates our ongoing commitment to accessibility by…
TX Text Control 33.0 SP2 is Now Available: What's New in the Latest Version
TX Text Control 33.0 Service Pack 2 is now available, offering important updates and bug fixes for all platforms. If you use TX Text Control in your document processing applications, this service…