Looking at the function UltraFormattedTextEditor.EditInfo.GetCurrentStyle() I'm wondering if there's any way to do the opposite -> SetCurrentStyle?
My goal is to clear a certain style from the current state style. Toggling bold on/off by using the UltraFormattedTextEditor.PerformAction() doesn't work as it only sets the current state style to font-weight:bold or font-weight:normal. I want it completely cleared.
Using UltraFormattedTextEditor.EditInfo.ClearStyleAttributes() works for this when text is selected but I want to change the current state style for the caret meaning it will be applied for the next typed char.
Thanks
Hello,
I have logged this as a development issue.
Hi,
Ah, I see. I missed that part - I thought you were trying to modify existing text, not change the next characters that are being typed by the user.
I tried this out and it looks like the ClearAllStyleAttributes method is supposed to be doing what you want, but it's not working. This is a bug.
I'm going to forward this thread over to Infragistics Developer Support so that they can write this up and get it fixed.
In the mean time, I notice that using keyboard shortcuts like Ctrl+B work correctly. So you might be able to acheive what you want in a roundabout way by toggling the states that are on.Something like this:
StyleInfo si = this.ultraFormattedTextEditor1.EditInfo.GetCurrentStyle(); if (si.Appearance.FontData.Bold == Infragistics.Win.DefaultableBoolean.True) { this.ultraFormattedTextEditor1.PerformAction(FormattedLinkEditorAction.ToggleBold, false, false); } if (si.Appearance.FontData.Italic == Infragistics.Win.DefaultableBoolean.True) { this.ultraFormattedTextEditor1.PerformAction(FormattedLinkEditorAction.ToggleItalics, false, false); }
ClearAllStyleAttributes() would work. Unfourtnatley it does not work as I think it would. Maybe it's a bug?
Ex:
1. ApplyStyle bold
2. Type "123" (Displayed in bold)
3. Call ClearAllStyleAttributes()
4. Type "456". ( The string "456" is getting displayed/formatted with bold even though I've just called Clear )
Output: 123456
Expected output: 123456
Selecting the entire string "123456" after it's typed and then calling ClearAllStyleAttributes() works but thats not what I want. I want to change the current style for new typed characters rather than by selecting already existing text.
How about this?
this.ultraFormattedTextEditor1.EditInfo.ClearAllStyleAttributes();
Or do you only want to clear the font-weight and nothing else? In that case, I think you would have to get the style and then re-apply the style without specifying a font-weight.