、あなたのイメージは、データベースに格納されたByteArray形式で取得されます。あなたはビットマップイメージにByteArrayのストリームを変換する必要があります。
Image _image = new Bitmap(new MemoryStream((Byte[])read[3]));
この画像は、複数の方法で参照する必要があるため、クラスレベルでそれを定義します。
listView1.OwnerDraw = true;
は、データソースから項目を取得します:
using System.Drawing;
using System.Drawing.Text;
Image _image;
は、サブアイテムは画像を表示するようにするには、アイテムにyourselftペイントので、あなたのリストビューのOwnerDrawするプロパティを設定する必要があります
(... LOOP ...)
//Define a new ListView Item...
ListViewItem _LVItem = new ListViewItem(read[0].ToString());
ListViewItem.ListViewSubItemCollection _ItemsCollection =
new ListViewItem.ListViewSubItemCollection(_LVItem);
//... and SubItems
_ItemsCollection.Add(new ListViewItem.ListViewSubItem(_LVItem, read[1].ToString()));
_ItemsCollection.Add(new ListViewItem.ListViewSubItem(_LVItem, read[2].ToString()));
//No text here, this is where the image will be drawn
_ItemsCollection.Add(new ListViewItem.ListViewSubItem(_LVItem, ""));
//Create a new Bitmap using a MemoryStream
_image = new Bitmap(new MemoryStream((Byte[])read[3]));
listView1.Items.Add(_LVItem);
(... LOOP ...)
listView1.DrawColumnHeader
とlistView1.DrawSubItem
ためのEventHandlerを作成します。
//You need to draw both Headers...
private void listView1_DrawColumnHeader(object sender, DrawListViewColumnHeaderEventArgs e)
{
e.Graphics.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
//Let the system draw these headers, nothing to do here
e.DrawDefault = true;
}
//... and SubItems
private void listView1_DrawSubItem(object sender, DrawListViewSubItemEventArgs e)
{
//If this is the column where the image is shown, draw it
if (e.ColumnIndex == 3)
{
//Position the image in the middle of its Column
//This will be re-calculated when the Column is resized
int _XLocation = (e.SubItem.Bounds.X +
(e.SubItem.Bounds.Width/2) -
(e.SubItem.Bounds.Height/2));
//Draw the Image resized to the Height of the row
e.Graphics.DrawImage(_image, new Rectangle(_XLocation, e.SubItem.Bounds.Y, e.SubItem.Bounds.Height, e.SubItem.Bounds.Height));
}
//Draw the other columns using their pre-defined values
e.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;
e.Graphics.DrawString(e.SubItem.Text,
e.SubItem.Font,
new SolidBrush(e.SubItem.ForeColor),
e.SubItem.Bounds.Location.X,
e.SubItem.Bounds.Location.Y);
}
そして、これが結果です:親愛なる、エラー何

? –
それはインデックス[3] –
のsystem.Byte []のみを表示するので、より詳細な質問を改善する必要があります。 –