Posted 8 September 2017, 2:05 pm EST
I am not sure if there is a best way to implement this, but I generally have an idea.
I would like an image celltype which has row/column span. The image is a snapshot of a panel which contains report.
When I resize the column it should redraw the image to make it fit to the size instead of stretch or scale.
To achieve this, i create a CustomCelltype which implement ImageCellType:
Public Class ReportCellType
Private mPanel As ReportPanel = Nothing
Private mPanelImage As Bitmap = Nothing
Public Sub New(ByVal panel As ReportPanel )
mPanel = panel
mPanel.Visible = True
Public Overrides Sub PaintCell(ByVal g As System.Drawing.Graphics, ByVal r As System.Drawing.Rectangle, ByVal appearance As FarPoint.Win.Spread.Appearance, ByVal value As Object, ByVal isSelected As Boolean, ByVal isLocked As Boolean, ByVal zoomFactor As Single)
Dim nr As System.Drawing.Rectangle = r
If mPanelImage Is Nothing OrElse r.Size <> mPanel.Size Then
mPanel.Size = r.Size
mPanel.Render(value) 'This will draw the image and etc to the panel
mPanel.Visible = True
mPanelImage = New Bitmap(r.Size.Width, r.Size.Height, Imaging.PixelFormat.Format64bppPArgb)
nr = New Rectangle(New Point(0, 0), r.Size)
g.FillRectangle(New SolidBrush(appearance.BackColor), nr)
MyBase.PaintCell(g, nr, appearance, mPanelImage, isSelected, isLocked, zoomFactor)
In my Spread, I set the the value of the Cell
mSpread.Cell(row,col) = New ReportCellType(panel)
The value object is neither a picture or an image. It is an object which is required for Panel to work out what to draw.
Is this the right way to achieve when Column get resize the image get redraw? or if there is any other better way?
The reason I am asking this is because even it achieve the result I wanted, but, it also showing something weird when I do print preview.
There is a white cell which looks like a focus stuff located at the corner. I also checked during PaintCell, the image doesn't have white cell. So, I am wondering where this WhiteCell coming from.
See image. My report is blue color.
The white cell come up when I do print preview. Then, if I close print preview, scroll down the row, and mouse move near that white cell, the white cell suddenly disappear.
After the white cell disappear, it won't happen again until I do a print preview.
I was wondering if anyone also having the same problem?