Home Forums WinForms controls Xceed Grid for WinForms Custom Image Viewer

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

    HI,
    I have a custom class which displays images(inherits cell Viewer Manager). It works good but the problem I am having is with printing data. I use PaintCellBackground and PaintCellForeground to custom paint image. I tried to use Reporting tool and it shows only the text data and not the images. I am pasting my custom class code.

    Thanks

    using System;

    using System.Text;

    using Xceed.Grid.Viewers;

    using Xceed.Grid;

    using System.Drawing;

    using System.Drawing.Drawing2D;

    using System.IO;

    namespace ChemicalControls

    {

    class SingleRecordImageViewer : CellViewerManager

    {

    public SingleRecordImageViewer(System.Drawing.Image img)
    {
    {
    this.ValueImage = null;
    System.Drawing.Bitmap imgNew = new Bitmap(new Bitmap(img));
    this.ValueImage = imgNew;
    img.Dispose();
    img = null;

    }

    }

    public SingleRecordImageViewer()

    : base()

    {

    }

    protected override void PaintCellBackground( Cell cell, GridPaintEventArgs e, ref bool handled )

    {

    if( ( cell.Value != null ) && ( cell.Value != DBNull.Value ) && ( cell.Value != cell.NullValue ) )
    {
    int x = e.DisplayRectangle.X;

    int y = e.DisplayRectangle.Y + ( ( e.DisplayRectangle.Height – this.ValueImage.Height ) / 2 );

    e.Graphics.DrawImage(this.ValueImage,e.DisplayRectangle.X,e.DisplayRectangle.Y);

    }

    // Notify the cell that its background has been painted by the CellViewerManager.

    handled = true;

    }

    protected override void PaintCellForeground( Cell cell, GridPaintEventArgs e, ref bool handled )

    {

    // Notify the cell that its foreground has been painted by the CellViewerManager.

    handled = true;

    }

    protected override int GetFittedHeightCore( Cell cell, AutoHeightMode mode, int cellDisplayWidth, Graphics graphics, bool printing )

    {

    return this.ValueImage.Height + 2;

    }

    private Image ValueImage;

    }

    }

    Imported from legacy forums. Posted by xUser (had 2635 views)

    User (Old forums)
    Member
    Post count: 23064

    This will not be possible built-in with the Xceed Grid for .NET. If anyone feels like sharing their solution or work around for this, please feel free to do so.

    Imported from legacy forums. Posted by Matt (had 399 views)

    User (Old forums)
    Member
    Post count: 23064

    From the documentation site:

    When generating a report using the reporting capabilities of Xceed Grid for .NET, CellViewerManagers will only be reproduced in the report if the GetImage and/or GetText methods return the image or text that is to be displayed (GetImageCore and/or GetTextCore have been overridden). In the case where the GetImageCore and/or GetTextCore methods have not been overridden to return the desired image and/or text, the string representation of the underlying cell’s content will be displayed in the report.

    Imported from legacy forums. Posted by hepkat (had 3531 views)

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