Ticket T163463
Visible to All Users

TreeList - How to implement the IPrintable interface

created 10 years ago

[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!

Answers approved by DevExpress Support

created 10 years ago (modified 10 years ago)

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).

    Show previous comments (3)
    DevExpress Support Team 10 years ago

      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 Basic
      Private 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?

        DevExpress Support Team 10 years ago

          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.

          Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

          Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.