I'm trying to print/preview an Infragistics UltraTree (winform) (version 14.2) which has formatted/markup text
The nodes of the tree use Infragistics.Win.FormattedLinkLabel.UltraFormattedTextEditor with TreatValueAs = FormattedLinkLabel.TreatValueAs.FormattedText
On the screen the tree looks nice. However when I use Infragistics.Win.Printing.UltraPrintPreviewDialog, the resulting tree displays each node with all of its markups.
The Node's Text
Is there a way to have the preview display the same way it looks on the screen? That is instead of the above, display "The Node's Text", where this text is printed in 11pt and the text color is navy.
The print version displays: span style='color:Navy; font-size:11pt; font-weight:bold; '> The Node's Text </span
Hello Greg,
I have investigated your issue, and I have asked our engineering staff to examine why editor component is not taken into account when printing the tree further. To ensure that it will receive attention, I have logged this behavior in our internal tracking system with a Development ID of #237272. So I’ve created a case for you CAS-184011-V4S2C8 and will update you for the progress of this issue via the mentioned case. You could reach your case following the link below:
https://es.infragistics.com/my-account/support-activity
In the meantime you can easily workaround this issue. What you need to do is handle InitializeTree event of UltraTreePrintDocument and set the EditorComponent like this:private void UltraTreePrintDocument1_InitializeTree(object sender, InitializeTreeEventArgs e)
{ e.Control.Override.EditorComponent = new UltraFormattedTextEditor();}
Thank you for using Infragistics Components.
This issue was fixed and fix was included in our latest service release for version 16.2 and 17.1. The fix is also included in all feature version of Infragistics for Windows Forms.
Thanks Milko!
I had to update a VB app and forgot about the "handles" clause.
This is the VB code if anyone needs it:
Private WithEvents printdoc As UltraTreePrintDocumentPrivate Sub PrintTreePreview() printdoc = New UltraTreePrintDocument Using printdoc printdoc.Tree = Me.BaseTree Using previewDialog As New Infragistics.Win.Printing.UltraPrintPreviewDialog() previewDialog.Document = printdoc previewDialog.ShowDialog(Me) End Using End UsingEnd SubPrivate Sub printDoc_InitializeTree(sender As Object, e As InitializeTreeEventArgs) _ Handles printdoc.InitializeTree e.Control.Override.EditorComponent = New UltraFormattedTextEditor()End Sub
Looking at your code you are actually not handling InitializeTree event of the UltraTreePrintDocument you are using. In PrintTreePreview method you are creating a new instance of local parameter printDoc. You either should add event handler to this new instance, or use your public property with same name. I suggest you to change your method like this:
private void PrintTreePreview(){ // Do not create a new local instance of UltraTreePrintDocument, but // a new instance of your public property // //using(UltraTreePrintDocument printDoc = new UltraTreePrintDocument()) using(this.printDoc = new UltraTreePrintDocument()) { printDoc.Tree = this.BaseTree; using(UltraPrintPreviewDialog previewDialog = new UltraPrintPreviewDialog()) { previewDialog.Document = printDoc; previewDialog.ShowDialog(this); } }}
Attached is my initial sample with your code added. Please check my sample and let me know if you have any additional questions on this matter.
Thank you Milko. I've tried your suggestion of handling the PrintDoc's InitializeTree event. But that even doesn't seem to fire, so perhaps I'm not using it correctly. Here is the code I'm using:
private UltraTreePrintDocument withEventsField_printDoc;
private UltraTreePrintDocument printDoc { get { return withEventsField_printDoc; } set { if (withEventsField_printDoc != null) { withEventsField_printDoc.InitializeTree -= printDoc_InitializeTree; } withEventsField_printDoc = value; if (withEventsField_printDoc != null) { withEventsField_printDoc.InitializeTree += printDoc_InitializeTree; } } }
private void PrintTreePreview() { using (UltraTreePrintDocument printDoc = new UltraTreePrintDocument()) { printDoc.Tree = this.BaseTree; using (Infragistics.Win.Printing.UltraPrintPreviewDialog previewDialog = new Infragistics.Win.Printing.UltraPrintPreviewDialog()) { previewDialog.Document = printDoc; previewDialog.ShowDialog(this); } } }
private void PrintTree(){ using (UltraTreePrintDocument printDoc = new UltraTreePrintDocument()) { printDoc.Tree = this.BaseTree; printDoc.Print(); } }
private void printDoc_InitializeTree(object sender, Printing.InitializeTreeEventArgs e) { e.Control.Override.EditorComponent = new FormattedLinkLabel.UltraFormattedTextEditor(); }