Hello,
I have a problem displaying formatted(no html tags, only line ends etc.) text on one of my forms. We originally used a standart UltraTextEditor control on the form, and it worked fine, but whenever a user would click the textbox (e.g. to select the text inside), the formatting would be lost immediately. Since this was a problem, I replaced the UltraTextEditor with an UltraFormattedTextEditor and I have more problems :-(
When the form is displayed(long after the Text property is set on the FormattedTextEditor control), the app displays a big red X over where the text should be, throws multiple exceptions:
System.Runtime.InteropServices.ExternalException: V rozhraní GDI+ došlo k obecné chybě. v System.Drawing.Graphics.MeasureCharacterRanges(String text, Font font, RectangleF layoutRect, StringFormat stringFormat) v Infragistics.Win.FormattedLinkLabel.PositionElementsCache.MeasureText(String text, Int32 startIndex, Int32 length, Font font) v Infragistics.Win.FormattedLinkLabel.NodeText.PositionSelf(PositionElementsInfo& info) v Infragistics.Win.FormattedLinkLabel.NodeBase.Position(PositionElementsInfo& info) v Infragistics.Win.FormattedLinkLabel.NodeBase.PositionChildNodes(PositionElementsInfo& info) v Infragistics.Win.FormattedLinkLabel.NodeBlock.PositionChildNodes(PositionElementsInfo& info) v Infragistics.Win.FormattedLinkLabel.NodeBase.Position(PositionElementsInfo& info) v Infragistics.Win.FormattedLinkLabel.NodeBase.PositionElements(IFormattedLinkLabelOwner owner, UIElement containerElem, Rectangle containerRect, Boolean calcIdealLayoutSize, Size& layoutSize) v Infragistics.Win.FormattedLinkLabel.FormattedTextUIElement.PositionElementsHelper(Rectangle layoutRect, Boolean setElemRectToIdealSize) v Infragistics.Win.FormattedLinkLabel.FormattedLinkEmbeddableUIElement.PositionChildElements() v Infragistics.Win.UIElement.VerifyChildElements(ControlUIElementBase controlElement, Boolean recursive) v Infragistics.Win.FormattedLinkLabel.FormattedLinkEmbeddableUIElement.VerifyChildElements(ControlUIElementBase controlElement, Boolean recursive) v Infragistics.Win.UIElement.VerifyChildElements(ControlUIElementBase controlElement, Boolean recursive) v Infragistics.Win.UIElement.DrawHelper(Graphics graphics, Rectangle invalidRectangle, Boolean doubleBuffer, AlphaBlendMode alphaBlendMode, Boolean clipText, Boolean forceDrawAsFocused, Boolean preventAlphaBlendGraphics) v Infragistics.Win.UIElement.Draw(Graphics graphics, Rectangle invalidRectangle, Boolean doubleBuffer, AlphaBlendMode alphaBlendMode, Boolean forceDrawAsFocused, Boolean preventAlphaBlendGraphics) v Infragistics.Win.ControlUIElementBase.Draw(Graphics graphics, Rectangle invalidRectangle, Boolean doubleBuffer, AlphaBlendMode alphaBlendMode, Size elementSize, Boolean preventAlphaBlendGraphics) v Infragistics.Win.ControlUIElementBase.Draw(Graphics graphics, Rectangle invalidRectangle, Boolean doubleBuffer, AlphaBlendMode alphaBlendMode, Size elementSize) v Infragistics.Win.ControlUIElementBase.Draw(Graphics graphics, Rectangle invalidRectangle, Boolean doubleBuffer, AlphaBlendMode alphaBlendMode) v Infragistics.Win.UltraControlBase.OnPaint(PaintEventArgs pe) v System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer, Boolean disposeEventArgs) v System.Windows.Forms.Control.WmPaint(Message& m) v System.Windows.Forms.Control.WndProc(Message& m) v System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) v System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) v System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
and shuts down. I´ve worked around this by setting the TextRenderingMode property to GDI instead of default GDI plus. It works, but it is VERY slow - it takes it around 0.5 - 1 sec to react to scrolling or a CTRL+A keyboard shortcut. There are no events bound to the control, I´ve double checked.
I just need to display the text with the formatting intact, even after the user clicks the textbox. Plus, the CTRL+A functionality would be a nice bonus.
Here is a sample text that causes the sluggish behavior. You can imagine why I need it formatted:
-- Request Processing Engine-- Date: 12.4.2009--declare @readonly bit if 'True' = 'True'Set @readonly = 1 else Set @readonly = 0declare @periodID uniqueidentifier set @periodID = nullif @periodID = '00000000-0000-0000-0000-000000000000'set @periodID = nulldeclare @dateFrom datetime set @dateFrom = nullif '0001-01-01 00:00:00' <> '0001-01-01 00:00:00'set @dateFrom = '0001-01-01 00:00:00'declare @dateTo datetime set @dateTo = nullif '0001-01-01 00:00:00' <> '0001-01-01 00:00:00'set @dateTo = '0001-01-01 00:00:00'declare @date datetimeSet @date = current_timestampExec proc_T0061_DFITEM_save_sync @ID_0061 = '707e4875-c782-4cc3-9ffc-4d1eebb22313', @NAME_0061 = 'Souhlas s elektronickou komunikací', @KEY_0061 = '', @ATTRIBS_0061 = '<data showhistory="yes"><format forecolor="#800000" /><descr><![CDATA[Souhlas s elektronickou komunikací]]></descr></data>', @IDNO1_0061 = '', @CHANGEDATE_0001 = @date, @CHANGEUSER_0001 = 'AT_a', @DATATYPE_0061 = 'DropDown', @VALUELIST_0061 = 'Ano|Ano - není odborný zástupce|Ne', @SEARCHABLE_0061 = '1', @READONLY_0061 = @readonly, @ID_0060_DFGROUP = 'a9a63f56-774f-48e4-85d2-9d22dc206030', @ID_0061_PREDECESSOR = null, @SHOWONCARD_0061 = '1', @VALIDFROM_0061 = @dateFrom, @VALIDTO_0061 = @dateTo, @SORDER_0061 = 4, @ID_3800_PERIOD = @periodID, @FLAG_0001 = 'A'
Thank you for any help in advance
Filip
Edit:Almost forgot to add - using the 8.3
Hi Filip,
If UltraFormattedTextEditor is crashing your application, then unless you are having a threading issue of some kind, then that's clearly a bug, in which case you should create a small sample project demonstrating the crash and Submit an incident to Infragistics Developer Support.
GDI does tend to be slower than GDI+ and there's nothing we can do about that, unfortunately. That's just a fact of life when programming in DotNet.
Hi, was this ever fixed or tracked down? We're seeing this in 12.1.20121.2082. And it crashes when a large amount of text is set. In our case 153,602 chars. Is there an actual text size limit on an UltraFormattedTextEditor?
System.Runtime.InteropServices.ExternalException (0x80004005): A generic error occurred in GDI+. at System.Drawing.Graphics.MeasureCharacterRanges(String text, Font font, RectangleF layoutRect, StringFormat stringFormat) at Infragistics.Win.FormattedLinkLabel.PositionElementsCache.MeasureText(String text, Int32 startIndex, Int32 length, Font font) at Infragistics.Win.FormattedLinkLabel.NodeText.NodeTextCache.GetWordSize(PositionElementsInfo info, String text, Int32 startIndex, Int32 length, Font font) at Infragistics.Win.FormattedLinkLabel.NodeText.PositionSelf(PositionElementsInfo& info) at Infragistics.Win.FormattedLinkLabel.NodeBase.PositionHelper(PositionElementsInfo& info) at Infragistics.Win.FormattedLinkLabel.NodeBase.PositionChildNodes(PositionElementsInfo& info) at Infragistics.Win.FormattedLinkLabel.NodeBlock.PositionChildNodes(PositionElementsInfo& info) at Infragistics.Win.FormattedLinkLabel.NodeBase.PositionElements(IFormattedLinkLabelOwner owner, UIElement containerElem, Rectangle containerRect, Boolean calcIdealLayoutSize, Size& layoutSize) at Infragistics.Win.FormattedLinkLabel.FormattedTextUIElement.PositionElementsHelper(Rectangle layoutRect, Boolean setElemRectToIdealSize) at Infragistics.Win.FormattedLinkLabel.FormattedLinkEmbeddableUIElement.PositionChildElements() at Infragistics.Win.UIElement.VerifyChildElements(ControlUIElementBase controlElement, Boolean recursive) at Infragistics.Win.FormattedLinkLabel.FormattedLinkEmbeddableUIElement.VerifyChildElements(ControlUIElementBase controlElement, Boolean recursive) at Infragistics.Win.UIElement.VerifyChildElements(ControlUIElementBase controlElement, Boolean recursive) at Infragistics.Win.UIElement.DrawHelper(Graphics graphics, Rectangle invalidRectangle, Boolean doubleBuffer, AlphaBlendMode alphaBlendMode, Boolean clipText, Boolean forceDrawAsFocused, Boolean preventAlphaBlendGraphics) at Infragistics.Win.UIElement.Draw(Graphics graphics, Rectangle invalidRectangle, Boolean doubleBuffer, AlphaBlendMode alphaBlendMode, Boolean forceDrawAsFocused, Boolean preventAlphaBlendGraphics) at Infragistics.Win.ControlUIElementBase.Draw(Graphics graphics, Rectangle invalidRectangle, Boolean doubleBuffer, AlphaBlendMode alphaBlendMode, Size elementSize, Boolean preventAlphaBlendGraphics) at Infragistics.Win.ControlUIElementBase.Draw(Graphics graphics, Rectangle invalidRectangle, Boolean doubleBuffer, AlphaBlendMode alphaBlendMode, Size elementSize) at Infragistics.Win.ControlUIElementBase.Draw(Graphics graphics, Rectangle invalidRectangle, Boolean doubleBuffer, AlphaBlendMode alphaBlendMode) at Infragistics.Win.UltraControlBase.OnPaint(PaintEventArgs pe) at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer) at System.Windows.Forms.Control.WmPaint(Message& m) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
I can't be 100% sure without a sample project that demonstrates the exception. But I am pretty sure that this was fixed. The latest Service Release for 12.1 was 12.1.20121.2135.
How to get the latest service release - Infragistics Community
The only thing i see in the bug fix notes is in 12.1.20121.2105 hot fix for "Editors Bug Fix Specific fonts render incorrectly." Otherwise I don't see anything specific for UltraFormattedTextEditor. There's clearly a text size limit in the UltraFormattedTextEditor?
lhardtke said:There's clearly a text size limit in the UltraFormattedTextEditor?
It depends what you mean by that. There's certainly no arbitrary hard-coded limit in the code. There are, of course, physical limitations of the amount of memory on your machine, so at a certain point, a string becomes too large for the machine to handle. But the FormattedTextEditor doesn't have anything to do with that. It's actually very efficient and only creates the elements it needs for what's in view.
Anyway, I'm sure the error message you are getting has nothing to do with the memory usage or the size of the text. And like I said, I'm pretty sure it's fixed in the service release. Have you tried it? You can always do a rollback if I am wrong and it doesn't help. And if that's the case, there's not much we can do without a sample duplicating the issue.