2

I don't know for sure about my ListBox, I have created one Listbox with Items, It's okay when I scroll up-down,but when I drawItem Image ( Image + Item Name) in addition I saw image with Item name, but has problem when scroll up - down.

what's problem?

user1417068
  • 82
  • 1
  • 9
  • My code is complicated, Because I get the SkypeKit.NET Tutorial 8, Skype tutorial 8 talking about conversation, but skype provide conversation list no avatar image and avialability, conversatoin name only!, I want to customize drawItem AvatarImage with Availability in ListBox, Now that listbox already draw, but error when I scroll listbox up-down, I don't no what happen when I scroll on it. – user1417068 May 30 '12 at 07:09
  • I had similar problem. Have you got something like that: `MyListBoxItem item = listBox1.Items[e.Index] as MyListBoxItem;` `if (item != null) {e.Graphics.DrawString(item.Message, listBox1.Font, SolidBrush(item.ItemColor), 0, e.Index * listBox1.ItemHeight); }` ? – JanOlMajti May 30 '12 at 10:19
  • Yes, Its' similar your, see the follow code: e.Graphics.DrawString(convers.P_DISPLAYNAME, e.Font, textBrush, e.Bounds.Left + 20, e.Bounds.Top + 5); e.Graphics.DrawImage(getContactImage(convers), e.Bounds.Left + 5, e.Bounds.Top + 5, 14, 14); – user1417068 May 30 '12 at 11:35
  • Not sure, but i bet there is something wrong with `getContactImage(convers)`. – JanOlMajti May 30 '12 at 11:47
  • Try it like http://msdn.microsoft.com/en-us/library/dbsak4dc.aspx and you will see, if the problem is stil there – JanOlMajti May 30 '12 at 11:52
  • Function getContactImage(convers) is a function get Image name that return like that : image.jpg, I was follow up with this code also, Image newImage = Image.FromFile("SampImag.jpg"); // Create coordinates for upper-left corner. // of image and for size of image. int x = 100; int y = 100; int width = 450; int height = 150; // Draw image to screen. e.Graphics.DrawImage(newImage, x, y, width, height); – user1417068 May 31 '12 at 04:16
  • And still the same problem? If is, then sorry, i don't know what's wrong.Should be working. – JanOlMajti May 31 '12 at 05:15

1 Answers1

1

Have you considered using a ListView instead of a ListBox similar as http://www.codeproject.com/Articles/13006/Extended-ListView or here

Community
  • 1
  • 1
JanOlMajti
  • 1,387
  • 4
  • 22
  • 34
  • A `ListView` is a specialized `ListBox`, so `ListBox` should be easyer. I recommend to try it. Here is some differences: http://stackoverflow.com/questions/227231/wpf-listbox-vs-listview-how-to-choose-for-data-binding, http://stackoverflow.com/questions/4703641/the-difference-between-listbox-and-listview and http://social.msdn.microsoft.com/Forums/is/wpf/thread/a89bea6e-31f6-483d-a7a2-252aca799f15 – JanOlMajti May 31 '12 at 11:27