private void listView_DrawSubItem(object sender, DrawListViewSubItemEventArgs e)
{
if (e.ColumnIndex == 1)
{
using (var ms = new MemoryStream())
{
using (var sw = new StreamWriter(ms))
{
sw.Write(e.SubItem.Text);
sw.Flush();
ms.Seek(0, SeekOrigin.Begin);
var rtb = new RichTextBox();
{
rtb.BorderStyle = BorderStyle.None;
rtb.LoadFile(ms, RichTextBoxStreamType.RichText);
rtb.Location = e.SubItem.Bounds.Location;
rtb.Size = e.SubItem.Bounds.Size;
rtb.Parent = sender as Control;
var bmp = new Bitmap(128, 32);
rtb.DrawToBitmap(bmp, rtb.DisplayRectangle);
//bmp.Save("test.bmp");
e.Graphics.DrawImageUnscaledAndClipped(bmp, e.SubItem.Bounds);
//e.DrawBackground();
//e.Graphics.DrawString(rtb.Text, SystemFonts.DefaultFont, SystemBrushes.ControlText, e.SubItem.Bounds);
}
}
}
}
else
{
e.DrawBackground();
e.DrawText();
}
}