We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Virtualized PictureBox cells

Hi

I load a huge amount of data into the grid (single column grid) where most of the rows contain images. The way I load image is

Dim sp As PictureBoxStyleProperties = New PictureBoxStyleProperties(e.Style)
sp.SizeMode = PictureBoxSizeMode.Zoom
sp.StyleInfo.HorizontalAlignment = GridHorizontalAlignment.Center
sp.StyleInfo.VerticalAlignment = GridVerticalAlignment.Middle

Dim fs As New System.IO.FileStream(imgPath, IO.FileMode.Open, FileAccess.Read)
Dim bm As New Bitmap(fs)
fs.Close()
fs = Nothing

sp.Image = bm

With this I get the Out of memory exception. So I wanted to make the image cells alone virtual. I expected thr QueryCellInfo event to be fired for a cell only when the cell is visible. But this is fired for all rows. I don't understand how to implement this.

Also when I load the grid initially I set a place holder image from the resource. Then when the grid is scrolled and a new image row becomes visible want to set the actual image to be displayed.

How can I do this?

Thanks a lot for your help. Its much appreciated.

Sudha


2 Replies

JS Jeba S Syncfusion Team January 10, 2008 01:41 PM UTC

Hi Sudha,

Currently we are working for this .We will update you within one business day.

Thank you for being patient.

Best regards,
Jeba.



HA haneefm Syncfusion Team January 10, 2008 04:02 PM UTC

Hi Sudha,

You can use the PrepareViewStyleInfo/QueryCellInfo event to shows the image in a gridcell on demand. PrepareviewStyleInfo event does not store any styleInfo properties in a grid. It just set the visual apperence of the grid. Here is a code snippet that shows this task.

Private Sub gridControl1_PrepareViewStyleInfo(ByVal sender As Object, ByVal e As PrepareViewStyleInfoEventArgs)
If e.ColIndex = 5 Then
Dim grid As GridControl = sender as GridControl
Dim cellRange As GridRangeInfo = GridRangeInfo.Cell(e.RowIndex,e.ColIndex)
If grid.ViewLay.VisibleCellsRange.IntersectsWith(cellRange) Then
'Visible Cell code here...
'e.Style.CellType = "PicturBoxCellType";
Else
'Non Visible Cells.
End If
End If
End Sub


Best regards,
Haneef


Loader.
Live Chat Icon For mobile
Up arrow icon