I have a dataset that returns an ImageKey, ImageDescription and the binary image. I am trying to load them as thumbnails into a UltraListView. I have the View property of the UltraListView set to thumbnails. When I run the code I get the listview with the generic bitmap for each entry and System.byte[] below each generic image. I can not figure out why the images in the database are not showing up. I know they are valid images. Any help is very much appreciated in advance.
Thanks
private void LoadThumbNails(){ string strKeyVal = ""; Infragistics.Win.UltraWinListView.UltraListViewItem i = new Infragistics.Win.UltraWinListView.UltraListViewItem(); foreach (DataRow r in dsImages.Tables[0].Rows) { strKeyVal = r["ImageKey"].ToString().Trim() + "-" + r["ImageDesc"].ToString().Trim(); try { object m_MyImage = (byte[])r["BinaryImage"]; ulvThumbnails.Items.Add(strKeyVal,m_MyImage); } catch (Exception e) { } }}
Code to do that would look something like the following:
private void LoadThumbNails(){ string strKeyVal = ""; Infragistics.Win.UltraWinListView.UltraListViewItem i = new Infragistics.Win.UltraWinListView.UltraListViewItem(); MemoryStream ms; foreach (DataRow r in dsImages.Tables[0].Rows) { strKeyVal = r["ImageKey"].ToString().Trim() + "-" + r["ImageDesc"].ToString().Trim(); try { byte[] byteArray = (byte[])r["BinaryImage"]; ms = new MemoryStream(bt); Image newImage = Image.FromStream(ms); UltraListViewItem item = new UltraListViewItem(strKeyVal); item.Appearance.Image = newImage;
ulvThumbnails.Items.Add(item); } catch (Exception e) {
} }}
You would have to create the Image using the Image.FromStream method, then assign it to the item's Appearance.Image property.