Author Topic: Return Drawing Preview to a listView Control c#  (Read 1581 times)

0 Members and 1 Guest are viewing this topic.

matinau

  • Guest
Return Drawing Preview to a listView Control c#
« on: March 23, 2012, 07:08:18 PM »
Really hope you can help,
I've been scouring the net trying to find a simple method to return an image to a listview with little success. How can I use the ReadDWGFile to send the associated dwg "bitmap" to a listview using c#. Currently my code only returns the filePath.

I found this on your site but couldn't get it to work

private void AddToImageList(string filename)
        {
            Database db = new Database(false, false);
            db.ReadDwgFile(filename, FileOpenMode.OpenForReadAndAllShare, false, null);
            Bitmap bitmap = db.ThumbnailBitmap;
            if (!(imgListLarge.Images.ContainsKey(filename)))
            {
                imgListLarge.Images.Add(filename, bitmap);
                imgListSmall.Images.Add(filename, bitmap);

            }
        }

...here's hoping

poncelet

  • Guest
Re: Return Drawing Preview to a listView Control c#
« Reply #1 on: March 24, 2012, 05:50:12 AM »
Code - vb.net: [Select]
  1.         Dim lv As ListView = your listview
  2.         Dim il As New ImageList
  3.  
  4.         'Then add your bitmaps into your imagelist...
  5.  
  6.         Dim lvi As ListViewItem
  7.         lv.MultiSelect = False
  8.         lv.LargeImageList = il
  9.  
  10.         For i = 0 To il.Images.Count - 1
  11.             lvi = New ListViewItem(enter name, i)
  12.             lv.Items.Add(lvi)
  13.         Next i
  14.  

You can use an imagelist. Hope that helps.

matinau

  • Guest
Re: Return Drawing Preview to a listView Control c#
« Reply #2 on: March 24, 2012, 07:21:06 PM »
legend! thank you. That worked but the image quality is pretty poor? Any tips? I've played around with ColorDepth property and ImageSize but there's still room for improvement.