Home Forums WinForms controls Xceed Grid for WinForms Problem Printing Custom Elements:

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #15758 |

    I have created a class deriving from the <b>TextRow</b> class and it shows up just fine in the Grid.

    However, when I print a report for the Grid it does not include my custom row (which happens to be a Fixed Header Row.)

    I’ve put a break-point in the Paint method that I overrode and it’s not even firing when printing the report.

    What am I missing?

    Regards,

    – Aaron.

    Imported from legacy forums. Posted by AaronY (had 4047 views)

    Xceed Support
    Member
    Post count: 5658

    I tried to reproduce this issue and I was not able to.

    I created a custom TextRow and added it to the FixedHeaderRows of my grid. The Grid included the TextRow using the GenerateReportForm class and the Report class.

    My custom TextRow:
    <code>
    public class MyTextRow : TextRow
    {
    public MyTextRow()
    : base()
    {
    }

    public MyTextRow( string text )
    : base( text )
    {
    }

    protected MyTextRow( MyTextRow template )
    : base( template )
    {
    }

    protected override Row CreateInstance()
    {
    return new MyTextRow( this );
    }

    public override Borders Borders
    {
    get
    {
    return base.Borders;
    }
    }

    protected override void PaintBorders( GridPaintEventArgs e )
    {
    base.PaintBorders( e );
    }

    protected override void PaintBackground( GridPaintEventArgs e )
    {
    base.PaintBackground( e );
    }

    protected override void PaintForeground( GridPaintEventArgs e )
    {
    base.PaintForeground( e );
    }
    }
    </code>

    The code I used to add the Custom TextRow and generate the Report:
    <code>
    MyTextRow newRow = new MyTextRow( “I’m a custom TextRow” );

    gridControl1.FixedHeaderRows.Add( newRow );

    Report report = new Report( gridControl1 );
    report.PrintPreview();
    </code>

    Imported from legacy forums. Posted by CharlesB (had 239 views)

    User (Old forums)
    Member
    Post count: 23064

    Thanks for the reply, when I used your example, it worked for me too, however I played around a little more and it seems that the custom class isn’t used when printing, example:
    <code>
    public class CustomTextRow : TextRow
    {
    public CustomTextRow() : base() { }
    public CustomTextRow(string text) : base(text) { }
    protected CustomTextRow(CustomTextRow template) : base(template) { }

    protected override Row CreateInstance()
    {
    return new CustomTextRow(this);
    }

    protected override void PaintForeground(GridPaintEventArgs e)
    {
    using (SolidBrush brush = new SolidBrush(this.ForeColor))
    {
    e.Graphics.DrawString(“Print Me: ” + this.Text, this.Font, brush, e.ClientRectangle);
    }
    }
    }
    </code>

    You’ll notice that on the grid you’ll see the “Print Me: ” prefix, but not on the Report.

    Note: This isn’t the class I’m using in my application, it’s just a demonstration of the problem, my actual class positions text (which isn’t from the “Text” property) in multuiple spots along the row.

    Are the overridden paint methods of the class not used when printing? The “Printing” property of the arguments would suggest they are, but it doesn’t look like it to me, unless I’m missing something.

    Regards,

    – Aaron.

    Imported from legacy forums. Posted by AaronY (had 340 views)

    Xceed Support
    Member
    Post count: 5658

    I tested the behavior you described and I understand what you mean. I was able to reproduce. However, it is not possible to implement the equivalent for the reporting. We do not offer the possibility to customize the painting in the Reporting Class.

    On the other hand, if you use the Print/PrintPreview methods of the GridControl (GridControl.Print/PrintPreview), the custom PaintForeground (of the CustomTextRow) will be painted.

    Imported from legacy forums. Posted by CharlesB (had 237 views)

    User (Old forums)
    Member
    Post count: 23064

    Charles,

    Thanks for clearing that up. Unfortunately using the Grid’s Print/PrintPreview method isn’t a viable alternative, as we require the presentation of the reporting functionality.

    We will have to look at other ways of achieving the results we want within the confines of the Grid’s reporting functionality.

    Any idea whether custom painting is being considered for future versions of the Grid’s reporting functionality?

    Regards,

    – Aaron.

    Imported from legacy forums. Posted by AaronY (had 427 views)

    Xceed Support
    Member
    Post count: 5658

    For the moment, we do not have a time frame to offer as when (or if) this possibility will be offer.

    Imported from legacy forums. Posted by CharlesB (had 4997 views)

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.