One of the least commonly used properties of the Selection class is IsCommonValueSelected. I have recently assisted several customers with this property and thus would like to take this opportunity to explain its exact functionality.
This property informs on whether a certain attribute has the same value as the value of the complete selection.
This is very important, for example, to synchronize a customized button bar with the current formatting of the selected text like bold or italic.
Possible attributes are:
- Baseline: Specifies the attribute set through the Baseline property.
- Bold: Specifies the attribute set through the Bold property.
- FontName: Specifies the attribute set through the FontName property.
- FontSize: Specifies the attribute set through the FontSize property.
- ForeColor: Specifies the attribute set through the ForeColor property.
- FormattingStyle: Specifies the attribute set through the FormattingStyle property.
- Italic: Specifies the attribute set through the Italic property.
- Strikeout: Specifies the attribute set through the Strikeout property.
- TextBackColor: Specifies the attribute set through the TextBackColor property.
- Underline: Specifies the attribute set through the Underline property.
The following VB.NET code return true, if the complete selection is formatted in bold.
Dim IsSelected As Boolean = TextControl1.Selection.IsCommonValueSelected(TXTextControl.Selection.Attribute.Bold)