Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
105
Problems displaying formatted text
posted

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 = 0

declare @periodID uniqueidentifier 
set @periodID = null
if  @periodID = '00000000-0000-0000-0000-000000000000'
set @periodID = null

declare @dateFrom datetime 
set @dateFrom = null
if '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 = null
if '0001-01-01 00:00:00' <> '0001-01-01 00:00:00'
set @dateTo = '0001-01-01 00:00:00'

declare @date datetime
Set @date = current_timestamp

Exec 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