[DevExpress Support Team: CLONED FROM E8: How to implement the IPrintable interface]
Could you give a sample using the TreeList control? I am trying to accomplish the same thing as mentioned in this ticket (https://www.devexpress.com/Support/Center/Question/Details/Q536648). Thanks!
TreeList - How to implement the IPrintable interface
Answers approved by DevExpress Support
Hi Adam,
Your task is not completely clear to me. If I understand you correctly, you are talking about the WinForms TreeList control, but this control already implements the IPrintable interface (see the TreeList Class help topic for more information).
Hi Adam,
Thank you for the provided code snippet. I see the issue. Our developers are working on it in the scope of the following ticket: PrintableComponentContainer - Redefining the PrintableComponent property does not reset the inner Link that is used to create a document
The problem is that the inner PrintableComponentContainer document does not get reset when you change the PrintableComponent property value. To resolve this issue, use System.Reflection to manually reset the field value:
Visual BasicPrivate Sub detailInspection_BeforePrint(sender As Object, e As PrintEventArgs) Handles detailInspection.BeforePrint
Dim tlist As New TreeList()
tlist.Parent = New Form()
tlist.OptionsPrint.AutoWidth = True
tlist.OptionsView.AutoWidth = True
tlist.OptionsPrint.UsePrintStyles = True
Dim fi As System.Reflection.FieldInfo = GetType(WinControlContainer).GetField("link", BindingFlags.NonPublic Or BindingFlags.Instance)
fi.SetValue(pccResults, null)
...
tlist.BestFitColumns()
tlist.ExpandAll()
tlist.ForceInitialize()
pccResults.PrintableComponent = tlist
End Sub
That works great! Thanks! The only thing now is that the treelist is not printing the same width consistently. Notice in the attached PDF that the last treelist is a little wider than the first two. Is there anything I can do to make the widths consistent?
Hi Adam,
It is difficult to give you a precise answer without being able to examine your report implementation. In general, try changing the TreeList.Width property value to make it equal to the usable page width (Report.PageWidth - Report.Margins.Left - Report.Margins.Right). If the problem persists, provide me with a sample project for further research.