0

i have a sql database with 10000+ entries that's filled within a wpf listbox. i'd like to display an image based on an integer within a column of the table. i only have >10 choices for each integer, so i only need @ 10 images.

the question i have is, if a user scrolls down the listbox, what's the fastest way to link up an image to a value using c# and wpf?

i'd rather not use the address of the image in the column, as storage of the data is at a premium, i'd rather just match it.

here's what i mean:

someInt | SomeData

(DisplaySomeImageHere) | thisWouldBeTheNumber1
(DisplayOtherImageHere) | thisWouldBeTheNumber2
etc.

but i have thousands of entries. what would be the best way to scroll these and add the image the fastest way?

H.B.
  • 166,899
  • 29
  • 327
  • 400
thermacore
  • 129
  • 1
  • 3
  • 10
  • no, you guys don't get the question. it's not "what's the fastest way to populate the listbox", it's "what's the fastest way to match an image to a value from the sql database, then put it in the listbox?" – thermacore Mar 06 '12 at 18:26

2 Answers2

0

The fastest way to retrieve data from the SQL is by using the native SqlDataReader.

To display data, if you have a lots of items (10,000+ is consider a lots) you should check virtual mode.

Check out this other question:

How do I populate a ListView in virtual mode asynchronously

Community
  • 1
  • 1
Zyo
  • 1,934
  • 21
  • 25
0

To speed up scrolling in addition to Virtualization (which is on by default in ListBox) you should use Container Recycling.

<ListBox VirtualizingStackPanel.VirtualizationMode="Recycling" />

This should speed up scrolling because you won't be destroying containers as you scroll them out of view.

Raj Ranjhan
  • 3,869
  • 2
  • 19
  • 29