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);
About TX Text Control:TX Text Control was originally released in 1991, since then more than 40,000 copies have been sold. Starting off as a single, small DLL,
TX Text Control
has made its way through 16-bit DLL and VBX versions to today‘s
Enterprise edition with its .NET and ActiveX components. The recent
addition to the family,
TX Text Control .NET Server, offers all of
TX Text Control
advanced word processing functionality in an easy-to-use server-side
.NET component. Customers benefit from these years of experience, large
user base, and at the same time, appreciate developing with a mature,
reliable product.
Contact Informations:support@textcontrol.comNorth & South America:Phone: +1 704-370-0110
Phone: +1 877-462-4772 (toll free)
Europe:Phone: +49 (0)421 42 70 67 10
Asia Pacific:Phone: +886 2-2797-8508