Ticket T473049
Visible to All Users

How to show custom infos in then Designer for a inherited XRSubreport?

created 8 years ago

Hallo,
I have a inherited XRPanel and want to show in the designer my own Text.
I overrides the OnDraw-Sub --> It works fine.
Now I also have a own inherited XRSubreport. But here the Overrides do not work.
How can I show my Data in then Designer for a inherited XRSubreport?
Public Class MySubreport
  Inherits XRSubreport
  Protected Overrides Sub OnDraw(e As DrawEventArgs)
    If Me.DesignMode Then
      Dim F As New Font("Arial", 8)
      Dim FMT As New System.Drawing.StringFormat
      FMT.Alignment = StringAlignment.Center
      FMT.LineAlignment = StringAlignment.Center
      Dim sText = "Hallo" & vbCrLf & Me.GetType.Name
      Using BR As New SolidBrush(Color.Blue)
        e.UniGraphics.DrawString(sText, F, BR, e.Bounds, FMT)
      End Using
    Else
      MyBase.OnDraw(e)
    End If
  End Sub
End Class
Many Thanks.

Answers approved by DevExpress Support

created 8 years ago (modified 8 years ago)

Hi Torsten,
The OnDraw method is never called by the XRSubreport. If you wish to change the text displayed by this component at design-time, you'll need to create a proper report control and register a new brick type produced by this component: Creating Custom Controls. That is, a document is a collection of Visual Bricks - there are no controls and you should not rely on their properties (rather, you should access the properties at the Brick level). Moreover, any custom drawing is only visible in the print preview, it is not preserved in any of the available export formats. As for a real code example, please take a look at the following example here, I believe it is very close to what you're after: BrickExporter - Creation of a custom report control. In our particular case, the XRSubreport uses different presenters. You'll need to override XRSubreport.CreatePresenter and implement your own version of the DesignSubreportPresenter (by default, this presenter created a TextBrick with the subreport path information). This class is private, but you can easily replicate it. I see you own a source-based subscription, so take a look at the following directory for the source code: *C:\Program Files (x86)\DevExpress 14.1\Components\Sources\DevExpress.XtraReports\DevExpress.XtraReports\Native\Presenters*
Let me know if you find this information helpful.

    Comments (1)

      Hallo Yaroslav,
       it works perfect.
      thanks for this Info

      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.