Not sure why this isn't working, can anyone shed some light on this.

Not sure why this isn't working, can anyone shed some light on this.

 ListboxItem.ItemData.Bitmap.Loadfromfile(Path + Pathdelim + 'pics' + Pathdelim + 'thumbnail' + pathdelim +'303.jpg'); it doesn't load the bitmap for the icon strange.

full code :

ListBox1.Items.Add('Test'); // test to see if i can simple add item
  ListboxItem := TListBoxItem.Create(Listbox1);// actual item i want to add
  ListboxItem.Text := 'ProperItem';
  ListboxItem.ItemData.Accessory := TListBoxItemData.TAccessory(1);
  ListboxItem.ItemData.Bitmap.Create;
  ListboxItem.ItemData.Bitmap.Loadfromfile(Path + Pathdelim + 'pics' + Pathdelim + 'thumbnail' + pathdelim +'303.jpg');
  ListBox1.AddObject(Listboxitem);

Comments

  1. ListboxItem.ItemData.Bitmap.Create;

    should be

    ListboxItem.ItemData.Bitmap := TBitmap.Create;

    and the file you're trying to load is a JPG image, not an BMP image, so, you want to create a temporary TJPEGImage object in which you load it and assign it as:

    ListBoxItem.ItemData.Bitmap.Assign(SomeJPEGImageVar);

    have fun!

    ReplyDelete
  2. The file does exist, but for some reason it will not load. I tried changing the jpeg to a bmp still wouldn't load. I tried assigning a Jpeg still would not load.

    ReplyDelete

Post a Comment