I'm using the ObjectListView
controls set, specifically the DataListView
. Here is my code.
Datasource
of the control:
dataListView1.DataSource = this.ViewModel.DataSet;
where DataSet
is populated by:
this.ViewModel.DataSet = HSGlobals.ctx.Entities<Product>().All()
.Where(p => productIdList.Contains(p.Id)).Select(p => new
{
Nazwa = p.Name,
Kod = p.Code,
Dostępność = p.AvaibleQuantity,
Typ = p.ProductType.Name,
Miara = p.MeasureUnit.Name,
Grafika = p.ProductImage.Image
}).ToList();
Grafika
is a byte array - an image obtained from database.
When dataListView
is displayed, the Grafika
column shows only type of this field - System.byte[]
.
What I have to do to display just an image?
I've already tried ImageGetter
and Renderer
properties but no success.
Your initial approach should work, if you attach an instance of the BrightIdeasSoftware.ImageRenderer
to the Renderer of the column.
For the ImageRenderer, the image can be sourced from:
Assuming your byte-stream contains valid data to create a Bitmap this should do.
EDIT: Also make sure that the OwnerDraw
property of the OLV is set to true
, IIRC this is a requirement that custom images will be drawn.